aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <blino@mageia.org>2010-11-01 23:24:36 +0000
committerOlivier Blin <blino@mageia.org>2010-11-01 23:24:36 +0000
commit3028dd876e14b25242185b8cca4122bd83cc5d1f (patch)
treef6b9c1dda2b0a6a09822fe3632905ae954d12518
parent363b9c4f4d4a142433bc9d66ab51df173bf48ae9 (diff)
downloadiurt-3028dd876e14b25242185b8cca4122bd83cc5d1f.tar
iurt-3028dd876e14b25242185b8cca4122bd83cc5d1f.tar.gz
iurt-3028dd876e14b25242185b8cca4122bd83cc5d1f.tar.bz2
iurt-3028dd876e14b25242185b8cca4122bd83cc5d1f.tar.xz
iurt-3028dd876e14b25242185b8cca4122bd83cc5d1f.zip
use iurt_root_command to add user
-rwxr-xr-xiurt_root_command9
-rw-r--r--lib/Iurt/Chroot.pm3
2 files changed, 11 insertions, 1 deletions
diff --git a/iurt_root_command b/iurt_root_command
index 05b6cdc..d9d20fa 100755
--- a/iurt_root_command
+++ b/iurt_root_command
@@ -138,6 +138,9 @@ $run{todo} = [];
[ "", "umount", 1, "<directory>]",
"umount the given directory",
\&umount, "Unmounting" ],
+ [ "", "useradd", 3, "<directory> <username> [uid]",
+ "Add user in given chroot",
+ \&useradd, "Useradd" ],
);
open(my $LOG, ">&STDERR");
@@ -361,3 +364,9 @@ sub umount {
check_path_authorized($dir) or return;
return !system("umount", $dir);
}
+
+sub useradd {
+ my ($_run, $dir, $username, $o_uid) = @_;
+ check_path_authorized($dir) or return;
+ return !system('chroot', $dir, 'useradd', if_($o_uid, '-o', '--uid', $o_uid), $username);
+}
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index ba7227e..91ff0f1 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -556,7 +556,8 @@ sub build_chroot {
#
# CM: Choose a sub-500 uid to prevent collison with $luser
#
- system($sudo, 'chroot', $tmp_chroot, 'adduser', '-o', '--uid', 499, 'builder');
+ sudo($run, $config, "--useradd", $tmp_chroot, 'builder', 499);
+
# FIXME: <mrl> Be careful! Damn ugly hack right below!
sudo($run, $config, "--rm", "$tmp_chroot/var/lib/rpm/__db*");
sudo($run, $config, "--umount", "$tmp_chroot/proc");