summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-05-24 17:49:12 +0000
committerErmal <eri@pfsense.org>2010-05-24 17:49:12 +0000
commit0914b6bbe52483115638d0240e74112cac8cec96 (patch)
tree7e019185b9f924a7129729bab4edf6720126597f
parentf37caa93fe3382766f21e3c038e771664f9fbb1e (diff)
downloadpfsense-0914b6bbe52483115638d0240e74112cac8cec96.zip
pfsense-0914b6bbe52483115638d0240e74112cac8cec96.tar.gz
Use mwexec where it does not make sense to use popen for something that does not take any parameters. Create a function to actually remove a user from its groups when the user itself is deleted.
-rw-r--r--etc/inc/auth.inc31
1 files changed, 21 insertions, 10 deletions
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc
index 826582f..2e580b1 100644
--- a/etc/inc/auth.inc
+++ b/etc/inc/auth.inc
@@ -340,10 +340,10 @@ function local_user_del($user) {
if($debug)
log_error("Running: {$cmd}");
- $fd = popen($cmd, "w");
- fwrite($fd, $user['password']);
- pclose($fd);
+ mwexec($cmd);
+ /* Delete user from groups needs a call to write_config() */
+ local_group_del_user($user);
}
function local_user_set_password(& $user, $password) {
@@ -421,6 +421,22 @@ function local_user_set_groups($user, $new_groups = NULL ) {
local_group_set($group);
}
+function local_group_del_user($user) {
+ global $config;
+
+ if (!is_array($config['system']['group']))
+ return;
+
+ foreach ($config['system']['group'] as $group) {
+ if (is_array($group['member'])) {
+ foreach ($group['member'] as $idx => $uid) {
+ if ($user['uid'] == $uid)
+ unset($config['system']['group']['member'][$idx]);
+ }
+ }
+ }
+}
+
function local_group_set($group, $reset = false) {
global $debug;
@@ -446,9 +462,7 @@ function local_group_set($group, $reset = false) {
if($debug)
log_error("Running: {$cmd}");
- $fd = popen($cmd, "w");
- fwrite($fd, $user['password']);
- pclose($fd);
+ mwexec($cmd);
}
@@ -460,10 +474,7 @@ function local_group_del($group) {
if($debug)
log_error("Running: {$cmd}");
- $fd = popen($cmd, "w");
- fwrite($fd, $user['password']);
- pclose($fd);
-
+ mwexec($cmd);
}
function ldap_test_connection($authcfg) {
OpenPOWER on IntegriCloud