Compare commits

...

5 commits
0.11 ... 0.17

33 changed files with 187 additions and 153 deletions

View file

@ -2,7 +2,7 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
@ -14,9 +14,9 @@
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/> <classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/> <classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/> <classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.7.jar" sourcepath="lib/commons-lang3-3.7-sources.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.11.0.jar" sourcepath="lib/commons-io-2.11.0-sources.jar"/>
<classpathentry kind="lib" path="lib/devinsy-cmdexec-0.8.1.jar" sourcepath="lib/devinsy-cmdexec-0.8.1-sources.zip"/> <classpathentry kind="lib" path="lib/commons-lang3-3.12.0.jar" sourcepath="lib/commons-lang3-3.12.0-sources.jar"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.11.0.jar" sourcepath="lib/devinsy-strings-0.11.0-sources.zip"/> <classpathentry kind="lib" path="lib/devinsy-cmdexec-0.17.0.jar" sourcepath="lib/devinsy-cmdexec-0.17.0-sources.zip"/>
<classpathentry kind="lib" path="lib/commons-io-2.7.jar" sourcepath="lib/commons-io-2.7-sources.jar"/> <classpathentry kind="lib" path="lib/devinsy-strings-0.17.0.jar" sourcepath="lib/devinsy-strings-0.17.0-sources.zip"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View file

@ -10,9 +10,9 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@ -21,7 +21,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16

View file

@ -3,5 +3,5 @@
<fixed facet="jst.java"/> <fixed facet="jst.java"/>
<fixed facet="jst.utility"/> <fixed facet="jst.utility"/>
<installed facet="jst.utility" version="1.0"/> <installed facet="jst.utility" version="1.0"/>
<installed facet="jst.java" version="11"/> <installed facet="jst.java" version="17"/>
</faceted-project> </faceted-project>

View file

@ -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 18:12:14 CEST 2021
build.number=0 build.number=1

View file

@ -1,3 +1,3 @@
product.name=devinsy-unix product.name=devinsy-unix
product.revision.major=0 product.revision.major=0
product.revision.minor=11 product.revision.minor=17

Binary file not shown.

BIN
lib/commons-io-2.11.0.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -144,10 +144,8 @@ public class EtcGroupFile extends ChangeableFile
return result; return result;
} }
/** /* (non-Javadoc)
* This method returns the updated groups. * @see fr.devinsy.unix.util.ChangeableFile#refresh()
*
* @return the groups
*/ */
@Override @Override
public void refresh() public void refresh()

View file

@ -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;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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;
/** /**
@ -106,10 +99,8 @@ public class EtcPasswdFile extends ChangeableFile
return result; return result;
} }
/** /* (non-Javadoc)
* Updated users. * @see fr.devinsy.unix.util.ChangeableFile#refresh()
*
* @return the users
*/ */
@Override @Override
public void refresh() public void refresh()
@ -152,5 +143,3 @@ public class EtcPasswdFile extends ChangeableFile
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -23,7 +23,6 @@ import java.util.Vector;
/** /**
* The Class Group. * The Class Group.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class Group public class Group
{ {
@ -89,7 +88,9 @@ public class Group
} }
/** /**
* Gets the members.
* *
* @return the members
*/ */
public Vector<String> getMembers() public Vector<String> getMembers()
{ {
@ -102,7 +103,9 @@ public class Group
} }
/** /**
* Gets the name.
* *
* @return the name
*/ */
public String getName() public String getName()
{ {
@ -115,7 +118,9 @@ public class Group
} }
/** /**
* Gets the password.
* *
* @return the password
*/ */
public String getPassword() public String getPassword()
{ {
@ -128,7 +133,9 @@ public class Group
} }
/** /**
* Gid.
* *
* @return the int
*/ */
public int gid() public int gid()
{ {
@ -141,7 +148,9 @@ public class Group
} }
/** /**
* Members.
* *
* @return the vector
*/ */
public Vector<String> members() public Vector<String> members()
{ {
@ -154,7 +163,9 @@ public class Group
} }
/** /**
* Name.
* *
* @return the string
*/ */
public String name() public String name()
{ {
@ -167,7 +178,9 @@ public class Group
} }
/** /**
* Passwd.
* *
* @return the string
*/ */
public String passwd() public String passwd()
{ {
@ -180,7 +193,10 @@ public class Group
} }
/** /**
* Sets the gid.
* *
* @param gid
* the new gid
*/ */
public void setGid(final int gid) public void setGid(final int gid)
{ {
@ -188,7 +204,10 @@ public class Group
} }
/** /**
* Sets the name.
* *
* @param name
* the new name
*/ */
public void setName(final String name) public void setName(final String name)
{ {
@ -196,7 +215,10 @@ public class Group
} }
/** /**
* Sets the passwd.
* *
* @param password
* the new passwd
*/ */
public void setPasswd(final String password) public void setPasswd(final String password)
{ {
@ -204,7 +226,10 @@ public class Group
} }
/** /**
* Sets the password.
* *
* @param password
* the new password
*/ */
public void setPassword(final String password) public void setPassword(final String password)
{ {
@ -225,5 +250,3 @@ public class Group
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -24,11 +24,9 @@ import java.util.Vector;
/** /**
* The Class Groups. * The Class Groups.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class Groups extends Vector<Group> public class Groups extends Vector<Group>
{ {
private static final long serialVersionUID = 5802487312198869603L; private static final long serialVersionUID = 5802487312198869603L;
// static private final Logger logger = // static private final Logger logger =
@ -91,7 +89,11 @@ public class Groups extends Vector<Group>
} }
/** /**
* Gets the by gid.
* *
* @param gid
* the gid
* @return the by gid
*/ */
public Group getByGid(final int gid) public Group getByGid(final int gid)
{ {
@ -250,5 +252,3 @@ public class Groups extends Vector<Group>
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -35,7 +35,6 @@ import fr.devinsy.unix.acl.AclManager;
/** /**
* The Class Unix. * The Class Unix.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class Unix public class Unix
{ {
@ -51,8 +50,8 @@ public class Unix
* the text * the text
* @param path * @param path
* the path * the path
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void appendToFile(final String text, final String path) throws UnixException public static void appendToFile(final String text, final String path) throws UnixException
{ {
@ -99,6 +98,15 @@ public class Unix
return result; return result;
} }
/**
* Bash.
*
* @param command
* the command
* @return the string
* @throws CmdExecException
* the cmd exec exception
*/
public static String bash(final String... command) throws CmdExecException public static String bash(final String... command) throws CmdExecException
{ {
String result; String result;
@ -118,13 +126,13 @@ public class Unix
/** /**
* Chmod. * Chmod.
* *
* @param changes * @param changes
* the changes * the changes
* @param path * @param path
* the path * the path
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void chmod(final String changes, final String path) throws UnixException public static void chmod(final String changes, final String path) throws UnixException
{ {
@ -152,13 +160,13 @@ public class Unix
/** /**
* Clear acl. * Clear acl.
* *
* @param id * @param id
* the id * the id
* @param filePathName * @param filePathName
* the file path name * the file path name
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void clearAcl(final String id, final String filePathName) throws UnixException public static void clearAcl(final String id, final String filePathName) throws UnixException
{ {
@ -167,13 +175,13 @@ public class Unix
/** /**
* Clear acl group. * Clear acl group.
* *
* @param group * @param group
* the group * the group
* @param filePathName * @param filePathName
* the file path name * the file path name
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void clearAclGroup(final String group, final String filePathName) throws UnixException public static void clearAclGroup(final String group, final String filePathName) throws UnixException
{ {
@ -182,13 +190,13 @@ public class Unix
/** /**
* Clear acl user. * Clear acl user.
* *
* @param login * @param login
* the login * the login
* @param filePathName * @param filePathName
* the file path name * the file path name
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void clearAclUser(final String login, final String filePathName) throws UnixException public static void clearAclUser(final String login, final String filePathName) throws UnixException
{ {
@ -197,11 +205,11 @@ public class Unix
/** /**
* Creates the user account. * Creates the user account.
* *
* @param login * @param login
* the login * the login
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void createUserAccount(final String login) throws UnixException public static void createUserAccount(final String login) throws UnixException
{ {
@ -217,13 +225,13 @@ public class Unix
/** /**
* Creates the user account. * Creates the user account.
* *
* @param login * @param login
* the login * the login
* @param name * @param name
* the name * the name
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void createUserAccount(final String login, final String name) throws UnixException public static void createUserAccount(final String login, final String name) throws UnixException
{ {
@ -243,15 +251,15 @@ public class Unix
/** /**
* Creates the user account. * Creates the user account.
* *
* @param login * @param login
* the login * the login
* @param name * @param name
* the name * the name
* @param home * @param home
* the home * the home
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void createUserAccount(final String login, final String name, final String home) throws UnixException public static void createUserAccount(final String login, final String name, final String home) throws UnixException
{ {
@ -286,7 +294,7 @@ public class Unix
/** /**
* Creates the user account. * Creates the user account.
* *
* @param login * @param login
* the login * the login
* @param name * @param name
@ -295,8 +303,8 @@ public class Unix
* the home * the home
* @param password * @param password
* the password * the password
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void createUserAccount(final String login, final String name, final String home, final String password) throws UnixException public static void createUserAccount(final String login, final String name, final String home, final String password) throws UnixException
{ {
@ -317,11 +325,11 @@ public class Unix
/** /**
* Delete group. * Delete group.
* *
* @param group * @param group
* the group * the group
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void deleteGroup(final String group) throws UnixException public static void deleteGroup(final String group) throws UnixException
{ {
@ -346,7 +354,12 @@ public class Unix
} }
/** /**
* Delete user account.
* *
* @param login
* the login
* @throws UnixException
* the unix exception
*/ */
public static void deleteUserAccount(final String login) throws UnixException public static void deleteUserAccount(final String login) throws UnixException
{ {
@ -398,12 +411,12 @@ public class Unix
/** /**
* Gets the acl data. * Gets the acl data.
* *
* @param filePathName * @param filePathName
* the file path name * the file path name
* @return the acl data * @return the acl data
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static String getAclData(final String filePathName) throws UnixException public static String getAclData(final String filePathName) throws UnixException
{ {
@ -417,12 +430,12 @@ public class Unix
/** /**
* Gets the acl users. * Gets the acl users.
* *
* @param filePathName * @param filePathName
* the file path name * the file path name
* @return the acl users * @return the acl users
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static String[] getAclUsers(final String filePathName) throws UnixException public static String[] getAclUsers(final String filePathName) throws UnixException
{ {
@ -472,13 +485,13 @@ public class Unix
/** /**
* Link. * Link.
* *
* @param sourcePath * @param sourcePath
* the source path * the source path
* @param targetPath * @param targetPath
* the target path * the target path
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void link(final String sourcePath, final String targetPath) throws UnixException public static void link(final String sourcePath, final String targetPath) throws UnixException
{ {
@ -517,15 +530,15 @@ public class Unix
/** /**
* Modify login. * Modify login.
* *
* @param sourceLogin * @param sourceLogin
* the source login * the source login
* @param targetLogin * @param targetLogin
* the target login * the target login
* @param sourceHomeDirectory * @param sourceHomeDirectory
* the source home directory * the source home directory
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void modifyLogin(final String sourceLogin, final String targetLogin, final String sourceHomeDirectory) throws UnixException public static void modifyLogin(final String sourceLogin, final String targetLogin, final String sourceHomeDirectory) throws UnixException
{ {
@ -596,13 +609,13 @@ public class Unix
/** /**
* Recursive chmod. * Recursive chmod.
* *
* @param changes * @param changes
* the changes * the changes
* @param path * @param path
* the path * the path
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void recursiveChmod(final String changes, final String path) throws UnixException public static void recursiveChmod(final String changes, final String path) throws UnixException
{ {
@ -725,17 +738,17 @@ public class Unix
/** /**
* Sets the facl. * Sets the facl.
* *
* @param args * @param args
* the new facl * the new facl
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static void setfacl(final String... args) throws UnixException public static void setfacl(final String... args) throws UnixException
{ {
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 +758,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
@ -782,12 +795,13 @@ public class Unix
/** /**
* chfn [ -f full-name ] [ username ]. * chfn [ -f full-name ] [ username ].
* *
* @param login * @param login
* the login * the login
* @param newRealName * @param newRealName
* the new real name * the new real name
* @throws UnixException * @throws UnixException
* the unix exception
*/ */
public static void setRealName(final String login, final String newRealName) throws UnixException public static void setRealName(final String login, final String newRealName) throws UnixException
{ {
@ -854,7 +868,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 +959,3 @@ public class Unix
} }
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -21,7 +21,6 @@ package fr.devinsy.unix;
/** /**
* The Class User. * The Class User.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class User public class User
{ {
@ -409,5 +408,3 @@ public class User
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -24,7 +24,6 @@ import java.util.Vector;
/** /**
* The Class Users. * The Class Users.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class Users extends Vector<User> public class Users extends Vector<User>
{ {
@ -41,8 +40,12 @@ public class Users extends Vector<User>
super(); super();
} }
/* (non-Javadoc) /**
* @see java.util.Vector#addAll(java.util.Collection) * Adds the all.
*
* @param source
* the source
* @return true, if successful
*/ */
public boolean addAll(final Users source) public boolean addAll(final Users source)
{ {
@ -212,5 +215,3 @@ public class Users extends Vector<User>
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -113,11 +113,12 @@ public class AclManager
/** /**
* Gets the acl. * Gets the acl.
* *
* @param filePathName * @param filePathName
* the file path name * the file path name
* @return the acl * @return the acl
* @throws UnixException * @throws UnixException
* the unix exception
*/ */
public static Acl getAcl(final String filePathName) throws UnixException public static Acl getAcl(final String filePathName) throws UnixException
{ {
@ -215,10 +216,12 @@ public class AclManager
/** /**
* Gets the ACL data. * Gets the ACL data.
* *
* @param filePathName * @param filePathName
* the file path name * the file path name
* @return the acl data * @return the acl data
* @throws UnixException
* the unix exception
*/ */
public static String getAclData(final String filePathName) throws UnixException public static String getAclData(final String filePathName) throws UnixException
{ {
@ -288,7 +291,7 @@ public class AclManager
/** /**
* Checks if is used. * Checks if is used.
* *
* @param type * @param type
* the type * the type
* @param id * @param id
@ -299,8 +302,7 @@ public class AclManager
* the depth * the depth
* @return true, if is used * @return true, if is used
* @throws UnixException * @throws UnixException
* @throws Exception * the unix exception
* the exception
*/ */
public static boolean isUsed(final AclEntry.Type type, final String id, final String filePathName, final int depth) throws UnixException public static boolean isUsed(final AclEntry.Type type, final String id, final String filePathName, final int depth) throws UnixException
{ {
@ -341,7 +343,7 @@ public class AclManager
/** /**
* Checks if is used. * Checks if is used.
* *
* @param type * @param type
* the type * the type
* @param id * @param id
@ -354,6 +356,7 @@ public class AclManager
* the depth * the depth
* @return true, if is used * @return true, if is used
* @throws UnixException * @throws UnixException
* the unix exception
*/ */
public static boolean isUsed(final AclEntry.Type type, final String id, final String filePath, final String[] filePathNames, final int depth) throws UnixException public static boolean isUsed(final AclEntry.Type type, final String id, final String filePath, final String[] filePathNames, final int depth) throws UnixException
{ {
@ -411,7 +414,7 @@ public class AclManager
/** /**
* Checks if is used. * Checks if is used.
* *
* @param id * @param id
* the id * the id
* @param filePathName * @param filePathName
@ -419,8 +422,8 @@ public class AclManager
* @param depth * @param depth
* the depth * the depth
* @return true, if is used * @return true, if is used
* @throws Exception * @throws UnixException
* the exception * the unix exception
*/ */
public static boolean isUsed(final String id, final String filePathName, final int depth) throws UnixException public static boolean isUsed(final String id, final String filePathName, final int depth) throws UnixException
{ {
@ -461,7 +464,7 @@ public class AclManager
/** /**
* Checks if is used. * Checks if is used.
* *
* @param id * @param id
* the id * the id
* @param filePathNames * @param filePathNames
@ -470,6 +473,7 @@ public class AclManager
* the depth * the depth
* @return true, if is used * @return true, if is used
* @throws UnixException * @throws UnixException
* the unix exception
*/ */
public static boolean isUsed(final String id, final String[] filePathNames, final int depth) throws UnixException public static boolean isUsed(final String id, final String[] filePathNames, final int depth) throws UnixException
{ {
@ -516,7 +520,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 +529,3 @@ public class AclManager
} }
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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;
@ -35,7 +36,6 @@ import fr.devinsy.unix.util.PropertyList;
/** /**
* The Class Linux. * The Class Linux.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class Linux public class Linux
{ {
@ -207,6 +207,7 @@ public class Linux
* *
* @return the string * @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String readProcCpuinfo0() throws IOException public static String readProcCpuinfo0() throws IOException
{ {
@ -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;
@ -264,12 +265,13 @@ public class Linux
* *
* @return the string * @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String readProcUptimeFile() throws IOException public static String readProcUptimeFile() throws IOException
{ {
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 +288,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 +311,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 +338,3 @@ public class Linux
return result; return result;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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,19 +20,11 @@ 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 ChangeableFile.
*
* @author Christian Pierre MOMON <christian.momon@devinsy.fr>
*/ */
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 +111,3 @@ public class ChangeableFile
this.sourceTime = 0; this.sourceTime = 0;
} }
} }
// ////////////////////////////////////////////////////////////////////////

View file

@ -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.
* *
@ -28,6 +28,11 @@ public class Property
/** /**
* Utility class has not to have a constructor. * Utility class has not to have a constructor.
*
* @param name
* the name
* @param value
* the value
*/ */
public Property(final String name, final String value) public Property(final String name, final String value)
{ {
@ -35,21 +40,43 @@ public class Property
this.value = value; this.value = value;
} }
/**
* Gets the name.
*
* @return the name
*/
public String getName() public String getName()
{ {
return this.name; return this.name;
} }
/**
* Gets the value.
*
* @return the value
*/
public String getValue() public String getValue()
{ {
return this.value; return this.value;
} }
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(final String name) public void setName(final String name)
{ {
this.name = name; this.name = name;
} }
/**
* Sets the value.
*
* @param value
* the new value
*/
public void setValue(final String value) public void setValue(final String value)
{ {
this.value = value; this.value = value;