summaryrefslogtreecommitdiff
path: root/lib/nss_wrapper
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-05-27 22:35:14 +0200
committerKarolin Seeger <kseeger@samba.org>2009-06-02 08:59:25 +0200
commit110b458d18c2760e9d6b1fe790eb23783e1dd510 (patch)
tree6e741f47be9b22b36cdb451e2e5ed178c8b88b1c /lib/nss_wrapper
parentda45972d859499da1296d5b915895d7d46015cb5 (diff)
downloadsamba-110b458d18c2760e9d6b1fe790eb23783e1dd510.tar.gz
nss_wrapper: split out passwd and group paths in nss_wrapper.pl.
Guenther (cherry picked from commit 7bb9e08d7e75be88a9788563f053794554f680a8) (cherry picked from commit 8bda8295ffc6fa9a9776f821b11075b6bac7a80d)
Diffstat (limited to 'lib/nss_wrapper')
-rw-r--r--lib/nss_wrapper/nss_wrapper.pl41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/nss_wrapper/nss_wrapper.pl b/lib/nss_wrapper/nss_wrapper.pl
index cfd3206c2ae..89958245ca4 100644
--- a/lib/nss_wrapper/nss_wrapper.pl
+++ b/lib/nss_wrapper/nss_wrapper.pl
@@ -7,7 +7,8 @@ use Getopt::Long;
use Cwd qw(abs_path);
my $opt_help = 0;
-my $opt_path = undef;
+my $opt_passwd_path = undef;
+my $opt_group_path = undef;
my $opt_action = undef;
my $opt_type = undef;
my $opt_name = undef;
@@ -23,7 +24,8 @@ sub group_delete($$);
my $result = GetOptions(
'help|h|?' => \$opt_help,
- 'path=s' => \$opt_path,
+ 'passwd_path=s' => \$opt_passwd_path,
+ 'group_path=s' => \$opt_group_path,
'action=s' => \$opt_action,
'type=s' => \$opt_type,
'name=s' => \$opt_name
@@ -39,7 +41,8 @@ sub usage($;$)
--help|-h|-? Show this help.
- --path <path> Path of the 'passwd' or 'group' file.
+ --passwd_path <path> Path of the 'passwd' file.
+ --group_path <path> Path of the 'group' file.
--type <type> Only 'passwd' and 'group' are supported yet,
maybe 'member' will be added in future.
@@ -55,18 +58,6 @@ usage(1) if (not $result);
usage(0) if ($opt_help);
-if (not defined($opt_path)) {
- usage(1, "missing: --path <path>");
-}
-if ($opt_path eq "" or $opt_path eq "/") {
- usage(1, "invalid: --path <path>: '$opt_path'");
-}
-my $opt_fullpath = abs_path($opt_path);
-if (not defined($opt_fullpath)) {
- usage(1, "invalid: --path <path>: '$opt_path'");
-}
-
-
if (not defined($opt_action)) {
usage(1, "missing: --action [add|delete]");
}
@@ -83,10 +74,13 @@ if ($opt_action eq "add") {
if (not defined($opt_type)) {
usage(1, "missing: --type [passwd|group]");
}
+my $opt_fullpath;
if ($opt_type eq "passwd") {
$actionfn = $passwdfn;
+ $opt_fullpath = check_path($opt_passwd_path, $opt_type);
} elsif ($opt_type eq "group") {
$actionfn = $groupfn;
+ $opt_fullpath = check_path($opt_group_path, $opt_type);
} else {
usage(1, "invalid: --type [passwd|group]: '$opt_type'")
}
@@ -100,6 +94,23 @@ if ($opt_name eq "") {
exit $actionfn->($opt_fullpath, $opt_name);
+sub check_path($$)
+{
+ my ($path,$type) = @_;
+
+ if (not defined($path)) {
+ usage(1, "missing: --$type\_path <path>");
+ }
+ if ($path eq "" or $path eq "/") {
+ usage(1, "invalid: --$type\_path <path>: '$path'");
+ }
+ my $fullpath = abs_path($path);
+ if (not defined($fullpath)) {
+ usage(1, "invalid: --$type\_path <path>: '$path'");
+ }
+ return $fullpath;
+}
+
sub passwd_add_entry($$);
sub passwd_load($)