diff options
Diffstat (limited to 'iurt_root_command')
| -rwxr-xr-x | iurt_root_command | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/iurt_root_command b/iurt_root_command index 87b5c5e..5dbc4f5 100755 --- a/iurt_root_command +++ b/iurt_root_command @@ -24,7 +24,7 @@ use strict; my $program_name = 'iurt_root_command'; use Mkcd::Commandline qw(parseCommandLine usage); use MDK::Common qw(any if_); -use File::NCopy qw(copy); +use File::Copy qw(copy); use Iurt::Util qw(plog_init plog); use Cwd 'realpath'; use File::Path qw(make_path); @@ -45,7 +45,7 @@ $run{todo} = []; # [ "", $program_name, 0, "[--verbose <level>] [--modprobe <module>] - [--mkdir [--parents] <dir1> <dir2> ... <dirn>]", + [--mkdir [--parents] [--mode <mode>] <dir1> <dir2> ... <dirn>]", "$program_name is a perl script to execute commands which need root privilege, it helps probram which needs occasional root privileges for some commands.", sub { $arg or usage($program_name, \@params) }, String::Escape::elide(join(' ', "Running $program_name", @ARGV), 120) ], @@ -77,7 +77,7 @@ $run{todo} = []; \&ln, "Linking files" ], [ "", "mkdir", [ - ["", "mkdir", -1, "[--parents] <dir1> <dir2> ... <dirn>", "mkdir create the given path", + ["", "mkdir", -1, "[--parents] [--mode <mode>] <dir1> <dir2> ... <dirn>", "mkdir create the given path", sub { my ($tmp, @arg) = @_; $tmp->[0] ||= {}; @@ -87,7 +87,10 @@ $run{todo} = []; ["p", "parents", 0, "", "Also create needed parents directories", sub { my ($tmp) = @_; $tmp->[0]{parents} = 1; 1 }, "Set the parents flag"], - ], "[--parents] <dir1> <dir2> ... <dirn>", + ["m", "mode", 1, "", + "Set the given mode on created directories", + sub { my ($tmp, $arg) = @_; $tmp->[0]{mode} = $arg; 1 }, "Set the mode flag"], + ], "[--parents] [--mode <mode>] <dir1> <dir2> ... <dirn>", "mkdir create the given path", \&mkdir, "Creating the path" ], @@ -244,6 +247,9 @@ sub mkdir { } else { mkdir $path; } + if ($opt->{mode}) { + chmod $opt->{mode}, $path; + } } 1; } @@ -418,7 +424,7 @@ sub netns_create { check_path_authorized($dest) or return; my $nsname = basename($dest); system("ip", "netns", "add", $nsname) and return; - system("ip", "netns", "exec", $nsname, "ifconfig", "lo", "up"); + system("ip", "netns", "exec", $nsname, "ip", "link", "set", "lo", "up"); # We don't configure a DNS server so make sure one is not excepted system('sed', '-i', 's|^hosts:.*|hosts: files|', "$dest/etc/nsswitch.conf"); # Some packages want a default route |
