Re: Changing the user name
On Wednesday 14 May 2014 15:10:12 you wrote: > On Wed, May 14, 2014 at 1:38 PM, Tito wrote: > > On Wednesday 14 May 2014 12:33:45 you wrote: > >> On Tue, May 13, 2014 at 8:27 PM, Tito wrote: > >> > On Tuesday 13 May 2014 19:01:41 Laszlo Papp wrote: > >> >> Hi, > >> >> > >> >> is this possible? I am looking for something like "usermod -l" on > >> >> desktop. > >> > > >> > This is actually not supported by busybox. > >> > So far we are able to add and delete users or groups > >> > or add users to groups or delete users from groups. > >> > >> Is that by design or no one has stepped up yet doing the work? > > > > I suppose nobody needed that feature so far. > > OK, let us say I need this feature: > > * Is it acceptable to add it to busybox (at least with some configuration)? > > * Where would it fit, adduser, separate applet or somewhere else? > Separate applet (usermod ?) with the options that could not be done with the existing applets. usermod - modify a user account ( No) -a, --append -> adduser user group Add the user to the supplementary group(s). Use only with the -G option. (Don't know) -c, --comment COMMENT The new value of the user's password file comment field. It is normally modified using the chfn(1) utility. (Yes if -l) -d, --home HOME_DIR The user's new login directory. If the -m option is given, the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist. (Don't know) -e, --expiredate EXPIRE_DATE The date on which the user account will be disabled. The date is specified in the format -MM-DD. An empty EXPIRE_DATE argument will disable the expiration of the account. This option requires a /etc/shadow file. A /etc/shadow entry will be created if there were none. An empty EXPIRE_DATE argument will disable the expiration of the account. This option requires a /etc/shadow file. A /etc/shadow entry will be created if there were none. (Don't know) -f, --inactive INACTIVE The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of -1 disables the feature. This option requires a /etc/shadow file. A /etc/shadow entry will be created if there were none. (Don't know, but bb's policy is to create a group with the same username name and problematic for existing file ownership) -g, --gid GROUP The group name or number of the user's new initial login group. The group must exist. Any file from the user's home directory owned by the previous primary group of the user will be owned by this new group. The group ownership of files outside of the user's home directory must be fixed manually. (No -> adduser user group) -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list. (Yes) -l, --login NEW_LOGIN The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user's home directory or mail spool should probably be renamed manually to reflect the new login name. (no -> passwd -l) -L, --lock Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password. You can't use this option with -p or -U. Note: if you wish to lock the account (not only access with a password), you should also set the EXPIRE_DATE to 1. (yes if with -l) -m, --move-home Move the content of the user's home directory to the new location. This option is only valid in combination with the -d (or --home) option. usermod will try to adapt the ownership of the files and to copy the modes, ACL and extended attributes, but manual changes might be needed afterwards. (Don't know) -o, --non-unique When used with the -u option, this option allows to change the user ID to a non-unique value. (No -> passwd) -p, --password PASSWORD The encrypted password, as returned by crypt(3). Note: This option is not recommended because the pa
Re: Changing the user name
On Wed, May 14, 2014 at 1:38 PM, Tito wrote: > On Wednesday 14 May 2014 12:33:45 you wrote: >> On Tue, May 13, 2014 at 8:27 PM, Tito wrote: >> > On Tuesday 13 May 2014 19:01:41 Laszlo Papp wrote: >> >> Hi, >> >> >> >> is this possible? I am looking for something like "usermod -l" on desktop. >> > >> > This is actually not supported by busybox. >> > So far we are able to add and delete users or groups >> > or add users to groups or delete users from groups. >> >> Is that by design or no one has stepped up yet doing the work? > > I suppose nobody needed that feature so far. OK, let us say I need this feature: * Is it acceptable to add it to busybox (at least with some configuration)? * Where would it fit, adduser, separate applet or somewhere else? >> >> Alternatively, I have to look into the get/setpwent syscalls? >> > >> > Yes. You can take a look at libbb/update_passwd.c for inspiration >> > and you need to be root to perform the user name change. >> >> It does not seem to use setpwent/getpwent though. It seems to be >> fiddling with manual file opening and so on. Why is it like that? > > I think editing on a per line basis is easier in that you can simply > write the untouched lines to the new file and edit the field > of the line of interest without touching other fields. Fair enough, albeit there could have been a serialization posix method out of the passwd structure creating the string for convenience... ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Wednesday 14 May 2014 12:33:45 you wrote: > On Tue, May 13, 2014 at 8:27 PM, Tito wrote: > > On Tuesday 13 May 2014 19:01:41 Laszlo Papp wrote: > >> Hi, > >> > >> is this possible? I am looking for something like "usermod -l" on desktop. > > > > This is actually not supported by busybox. > > So far we are able to add and delete users or groups > > or add users to groups or delete users from groups. > > Is that by design or no one has stepped up yet doing the work? I suppose nobody needed that feature so far. > >> Alternatively, I have to look into the get/setpwent syscalls? > > > > Yes. You can take a look at libbb/update_passwd.c for inspiration > > and you need to be root to perform the user name change. > > It does not seem to use setpwent/getpwent though. It seems to be > fiddling with manual file opening and so on. Why is it like that? I think editing on a per line basis is easier in that you can simply write the untouched lines to the new file and edit the field of the line of interest without touching other fields. > Cheers, L. > Ciao, Tito ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Tue, May 13, 2014 at 8:27 PM, Tito wrote: > On Tuesday 13 May 2014 19:01:41 Laszlo Papp wrote: >> Hi, >> >> is this possible? I am looking for something like "usermod -l" on desktop. > > This is actually not supported by busybox. > So far we are able to add and delete users or groups > or add users to groups or delete users from groups. Is that by design or no one has stepped up yet doing the work? >> Alternatively, I have to look into the get/setpwent syscalls? > > Yes. You can take a look at libbb/update_passwd.c for inspiration > and you need to be root to perform the user name change. It does not seem to use setpwent/getpwent though. It seems to be fiddling with manual file opening and so on. Why is it like that? Cheers, L. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Wed, May 14, 2014 at 9:18 AM, Tito wrote: > On Wednesday 14 May 2014 08:28:59 Ralf Friedl wrote: >> Laszlo Papp wrote: >> > is this possible? I am looking for something like "usermod -l" on desktop. >> > >> > Alternatively, I have to look into the get/setpwent syscalls? >> You can also use sed to change /etc/passwd >> >> sed -i -e /s^olduser:/newuser:/ /etc/passwd > > Hi, > I think this is not enough. You have to: > > 1) change the user name in /etc/passwd > 2) change the user name in /etc/shadow (if shadow passwords are used) > 3) change the group name of the user if a group with the same name as user > name was created in /etc/group > 4) change the group name of the user if a group with the same name as user > name was created in /etc/gshadow (if shadow passwords are used) > 5) change user name if member of other groups in /etc/group > 6) change user name if member of other groups in in /etc/gshadow (if shadow > passwords are used) > 7) eventually change user's homedir in in /etc/passwd to reflect the new > username > 8) rename users home dir accordingly if needed > 9) rename users mail spool accordingly if needed > > Using sed if it is a multiuser system is not a good idea as there is no file > locking and backup mechanism and if a user decides to change his password > the same time you change a username file corruption could be possible. Good observation. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Wednesday 14 May 2014 08:28:59 Ralf Friedl wrote: > Laszlo Papp wrote: > > is this possible? I am looking for something like "usermod -l" on desktop. > > > > Alternatively, I have to look into the get/setpwent syscalls? > You can also use sed to change /etc/passwd > > sed -i -e /s^olduser:/newuser:/ /etc/passwd Hi, I think this is not enough. You have to: 1) change the user name in /etc/passwd 2) change the user name in /etc/shadow (if shadow passwords are used) 3) change the group name of the user if a group with the same name as user name was created in /etc/group 4) change the group name of the user if a group with the same name as user name was created in /etc/gshadow (if shadow passwords are used) 5) change user name if member of other groups in /etc/group 6) change user name if member of other groups in in /etc/gshadow (if shadow passwords are used) 7) eventually change user's homedir in in /etc/passwd to reflect the new username 8) rename users home dir accordingly if needed 9) rename users mail spool accordingly if needed Using sed if it is a multiuser system is not a good idea as there is no file locking and backup mechanism and if a user decides to change his password the same time you change a username file corruption could be possible. Ciao, Tito ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Wed, May 14, 2014 at 7:40 AM, Ralf Friedl wrote: > Laszlo Papp wrote: >> >> On Wed, May 14, 2014 at 7:28 AM, Ralf Friedl >> wrote: >>> >>> Laszlo Papp wrote: is this possible? I am looking for something like "usermod -l" on desktop. Alternatively, I have to look into the get/setpwent syscalls? >>> >>> You can also use sed to change /etc/passwd >>> >>> sed -i -e /s^olduser:/newuser:/ /etc/passwd >> >> Yeah, plus I need to move (i.e. rename) the home folder and then I >> think I am done. Thanks. > > You should note that usermod doesn't do that anyway: >-l, --login NEW_LOGIN >The name of the user will be changed from LOGIN to NEW_LOGIN. > Nothing else is changed. In particular, the user's home directory or mail > spool should probably be renamed manually to reflect the new login name. usermod does do that: -m, --move-home move contents of the home directory to the new location (use only with -d) ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
Laszlo Papp wrote: On Wed, May 14, 2014 at 7:28 AM, Ralf Friedl wrote: Laszlo Papp wrote: is this possible? I am looking for something like "usermod -l" on desktop. Alternatively, I have to look into the get/setpwent syscalls? You can also use sed to change /etc/passwd sed -i -e /s^olduser:/newuser:/ /etc/passwd Yeah, plus I need to move (i.e. rename) the home folder and then I think I am done. Thanks. You should note that usermod doesn't do that anyway: -l, --login NEW_LOGIN The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user's home directory or mail spool should probably be renamed manually to reflect the new login name. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Wed, May 14, 2014 at 7:28 AM, Ralf Friedl wrote: > Laszlo Papp wrote: >> >> is this possible? I am looking for something like "usermod -l" on desktop. >> >> Alternatively, I have to look into the get/setpwent syscalls? > > You can also use sed to change /etc/passwd > > sed -i -e /s^olduser:/newuser:/ /etc/passwd Yeah, plus I need to move (i.e. rename) the home folder and then I think I am done. Thanks. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
Laszlo Papp wrote: is this possible? I am looking for something like "usermod -l" on desktop. Alternatively, I have to look into the get/setpwent syscalls? You can also use sed to change /etc/passwd sed -i -e /s^olduser:/newuser:/ /etc/passwd ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Changing the user name
On Tuesday 13 May 2014 19:01:41 Laszlo Papp wrote: > Hi, > > is this possible? I am looking for something like "usermod -l" on desktop. This is actually not supported by busybox. So far we are able to add and delete users or groups or add users to groups or delete users from groups. > > Alternatively, I have to look into the get/setpwent syscalls? Yes. You can take a look at libbb/update_passwd.c for inspiration and you need to be root to perform the user name change. > Cheers, L. Ciao, Tito ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox