diff options
author | Phil Davis <phil.davis@inf.org> | 2015-03-18 17:48:36 +0545 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2015-03-18 10:58:58 -0300 |
commit | 5372d26d9d25d751d16865ed9d46869d3b0ec5e1 (patch) | |
tree | e00cf869ec9aa947ba9d77bc17598a5a7fdea273 /usr/local | |
parent | b13f7a8c58f573441568fe717f68b7e3989218c1 (diff) | |
download | pfsense-5372d26d9d25d751d16865ed9d46869d3b0ec5e1.zip pfsense-5372d26d9d25d751d16865ed9d46869d3b0ec5e1.tar.gz |
Cleanup code path when adding a new user
1) Only attempt to delete the oldusername if it actually was non-empty - at the moment errors are logged in the system log when adding a new user, because the code was trying to delete the user name "".
2) Call local_user_set() first to create (change, whatever) the user record. This makes the user record exist for a new user. Then call local_user_set_groups() to sort out what groups the user should be in or not in. The existing code would fail to add a new user to the specified group/s because local_user_set_groups() was called too early, before the user actually existed.
Typical system log errors from the old code:
Mar 18 17:10:31 php-fpm[9542]: /system_usermanager.php: Tried to remove user but got user pw instead. Bailing.
Mar 18 17:10:31 php-fpm[9542]: /system_usermanager.php: The command '/usr/sbin/pw groupmod admins -g 1999 -M '0,2003,2006,2008' 2>&1' returned exit code '67', the output was 'pw: user `2008' does not exist'
From looking at the code history, I think this has been this way for a long time, not a new bug at all.
Discussed in forum: https://forum.pfsense.org/index.php?topic=90700.msg501766#msg501766
Diffstat (limited to 'usr/local')
-rw-r--r-- | usr/local/www/system_usermanager.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr/local/www/system_usermanager.php b/usr/local/www/system_usermanager.php index 9fce497..1bc91ad 100644 --- a/usr/local/www/system_usermanager.php +++ b/usr/local/www/system_usermanager.php @@ -299,7 +299,7 @@ if ($_POST['save']) { isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system"; /* the user name was modified */ - if ($_POST['usernamefld'] <> $_POST['oldusername']) { + if (!empty($_POST['oldusername']) && ($_POST['usernamefld'] <> $_POST['oldusername'])) { $_SERVER['REMOTE_USER'] = $_POST['usernamefld']; local_user_del($userent); } @@ -361,8 +361,8 @@ if ($_POST['save']) { $a_user[] = $userent; } - local_user_set_groups($userent,$_POST['groups']); local_user_set($userent); + local_user_set_groups($userent,$_POST['groups']); write_config(); if(is_dir("/etc/inc/privhooks")) |