Fixed deprecated code.
This commit is contained in:
parent
4494a74296
commit
c0d3fb7be0
8 changed files with 24 additions and 50 deletions
|
@ -1,3 +1,3 @@
|
||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Thu May 04 22:58:25 CEST 2017
|
#Thu Oct 14 16:30:13 CEST 2021
|
||||||
build.number=0
|
build.number=0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2010,2013-2014,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2006-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -65,7 +65,7 @@ public class EtcGroupFileReader
|
||||||
Group group = new Group();
|
Group group = new Group();
|
||||||
group.setName(tokens[0]);
|
group.setName(tokens[0]);
|
||||||
group.setPassword(tokens[1]);
|
group.setPassword(tokens[1]);
|
||||||
group.setGid((new Integer(tokens[2])).intValue());
|
group.setGid(Integer.valueOf(tokens[2]).intValue());
|
||||||
|
|
||||||
// Manage the case of empty shell.
|
// Manage the case of empty shell.
|
||||||
if (tokens.length == 4)
|
if (tokens.length == 4)
|
||||||
|
@ -105,5 +105,3 @@ public class EtcGroupFileReader
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2010,2013-2014,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2006-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -18,15 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.unix;
|
package fr.devinsy.unix;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import fr.devinsy.unix.util.ChangeableFile;
|
import fr.devinsy.unix.util.ChangeableFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class EtcPasswdFile.
|
* The Class EtcPasswdFile.
|
||||||
*
|
|
||||||
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
|
|
||||||
*/
|
*/
|
||||||
public class EtcPasswdFile extends ChangeableFile
|
public class EtcPasswdFile extends ChangeableFile
|
||||||
{
|
{
|
||||||
|
@ -36,8 +31,6 @@ public class EtcPasswdFile extends ChangeableFile
|
||||||
private static final EtcPasswdFile instance = new EtcPasswdFile();
|
private static final EtcPasswdFile instance = new EtcPasswdFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EtcPasswdFile.class);
|
|
||||||
|
|
||||||
private Users users;
|
private Users users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,5 +145,3 @@ public class EtcPasswdFile extends ChangeableFile
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2010,2013-2014,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2006-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* The Class EtcPasswdFileReader.
|
* The Class EtcPasswdFileReader.
|
||||||
*
|
*
|
||||||
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
|
|
||||||
*/
|
*/
|
||||||
public class EtcPasswdFileReader
|
public class EtcPasswdFileReader
|
||||||
{
|
{
|
||||||
|
@ -66,8 +65,8 @@ public class EtcPasswdFileReader
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setLogin(tokens[0]);
|
user.setLogin(tokens[0]);
|
||||||
user.setPassword(tokens[1]);
|
user.setPassword(tokens[1]);
|
||||||
user.setUid((new Integer(tokens[2])).intValue());
|
user.setUid(Integer.valueOf(tokens[2]).intValue());
|
||||||
user.setGid((new Integer(tokens[3])).intValue());
|
user.setGid(Integer.valueOf(tokens[3]).intValue());
|
||||||
user.setRealName(tokens[4]);
|
user.setRealName(tokens[4]);
|
||||||
user.setHomeDirectory(tokens[5]);
|
user.setHomeDirectory(tokens[5]);
|
||||||
|
|
||||||
|
@ -109,5 +108,3 @@ public class EtcPasswdFileReader
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2010,2013-2015,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2006-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -735,7 +735,7 @@ public class Unix
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String[] command = ArrayUtils.add(args, 0, "setfacl");
|
String[] command = ArrayUtils.insert(0, args, "setfacl");
|
||||||
sudo(command);
|
sudo(command);
|
||||||
}
|
}
|
||||||
catch (CmdExecException exception)
|
catch (CmdExecException exception)
|
||||||
|
@ -745,8 +745,8 @@ public class Unix
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As 'passwd' command has not the option '--stdin' in all systems (eg. Debian),
|
* As 'passwd' command has not the option '--stdin' in all systems (eg.
|
||||||
* this method uses the 'chpasswd' command.
|
* Debian), this method uses the 'chpasswd' command.
|
||||||
*
|
*
|
||||||
* @param login
|
* @param login
|
||||||
* the login
|
* the login
|
||||||
|
@ -854,7 +854,7 @@ public class Unix
|
||||||
|
|
||||||
if (SystemUtils.IS_OS_UNIX)
|
if (SystemUtils.IS_OS_UNIX)
|
||||||
{
|
{
|
||||||
String[] newCommand = ArrayUtils.add(command, 0, SUDO);
|
String[] newCommand = ArrayUtils.insert(0, command, SUDO);
|
||||||
result = CmdExecUtils.run(newCommand);
|
result = CmdExecUtils.run(newCommand);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -945,5 +945,3 @@ public class Unix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010,2013-2015,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2010-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -516,7 +516,7 @@ public class AclManager
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String[] newArgs = ArrayUtils.add(args, 0, "setfacl");
|
String[] newArgs = ArrayUtils.insert(0, args, "setfacl");
|
||||||
Unix.sudo(newArgs);
|
Unix.sudo(newArgs);
|
||||||
}
|
}
|
||||||
catch (CmdExecException exception)
|
catch (CmdExecException exception)
|
||||||
|
@ -525,5 +525,3 @@ public class AclManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2017-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,7 @@ package fr.devinsy.unix.linux;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ public class Linux
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
result = FileUtils.readFileToString(new File("/proc/cpuinfo"));
|
result = FileUtils.readFileToString(new File("/proc/cpuinfo"), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
@ -253,7 +254,7 @@ public class Linux
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
result = FileUtils.readFileToString(new File("/proc/meminfo"));
|
result = FileUtils.readFileToString(new File("/proc/meminfo"), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
@ -269,7 +270,7 @@ public class Linux
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
result = FileUtils.readFileToString(new File("/proc/uptime"));
|
result = FileUtils.readFileToString(new File("/proc/uptime"), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
@ -286,7 +287,7 @@ public class Linux
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
result = FileUtils.readFileToString(new File("/proc/version"));
|
result = FileUtils.readFileToString(new File("/proc/version"), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
@ -309,16 +310,16 @@ public class Linux
|
||||||
|
|
||||||
if (debianFile.exists())
|
if (debianFile.exists())
|
||||||
{
|
{
|
||||||
result = "Debian " + FileUtils.readFileToString(debianFile);
|
result = "Debian " + FileUtils.readFileToString(debianFile, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
else if (redhatFile.exists())
|
else if (redhatFile.exists())
|
||||||
{
|
{
|
||||||
result = FileUtils.readFileToString(redhatFile);
|
result = FileUtils.readFileToString(redhatFile, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
else if (suseFile.exists())
|
else if (suseFile.exists())
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
result = "SUSE " + FileUtils.readFileToString(debianFile);
|
result = "SUSE " + FileUtils.readFileToString(debianFile, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -336,5 +337,3 @@ public class Linux
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2010,2013-2014,2017-2018 Christian Pierre MOMON
|
* Copyright (C) 2006-2021 Christian Pierre MOMON
|
||||||
*
|
*
|
||||||
* This file is part of Devinsy-unix.
|
* This file is part of Devinsy-unix.
|
||||||
*
|
*
|
||||||
|
@ -20,9 +20,6 @@ package fr.devinsy.unix.util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CachedFile.
|
* The Class CachedFile.
|
||||||
*
|
*
|
||||||
|
@ -31,8 +28,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class ChangeableFile
|
public class ChangeableFile
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ChangeableFile.class);
|
|
||||||
|
|
||||||
private File sourceFile;
|
private File sourceFile;
|
||||||
private long sourceTime;
|
private long sourceTime;
|
||||||
|
|
||||||
|
@ -119,5 +114,3 @@ public class ChangeableFile
|
||||||
this.sourceTime = 0;
|
this.sourceTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
Loading…
Reference in a new issue