summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-06-25 01:15:17 +0000
committerAndrew Tridgell <tridge@samba.org>2001-06-25 01:15:17 +0000
commit53ca6d33ce46f29afdf3fa82ba0669ef88dd97e4 (patch)
tree3951291641ff73ab17b84070673a167d58adad2d /source3
parent8b79a473faf2ff25acb220500158920490c71576 (diff)
downloadsamba-53ca6d33ce46f29afdf3fa82ba0669ef88dd97e4.tar.gz
samba-53ca6d33ce46f29afdf3fa82ba0669ef88dd97e4.tar.bz2
samba-53ca6d33ce46f29afdf3fa82ba0669ef88dd97e4.zip
added a -L option to smbpasswd to force it to run locally so we can test smbpasswd as non-root
(This used to be commit ab635202655712a05b812ff40550d00d00552853)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/smbpasswd.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 00a7d3c1c1..b4576a603c 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -29,6 +29,9 @@ extern int DEBUGLEVEL;
extern char *optarg;
extern int optind;
+/* forced running in root-mode */
+static BOOL local_mode;
+
/*********************************************************
a strdup with exit
**********************************************************/
@@ -59,7 +62,8 @@ static void usage(void)
printf(" -U USER remote username\n");
printf(" -r MACHINE remote machine\n");
- if (getuid() == 0) {
+ if (getuid() == 0 || local_mode) {
+ printf(" -L local mode (must be first option)\n");
printf(" -R ORDER name resolve order\n");
printf(" -j DOMAIN join domain name\n");
printf(" -a add user\n");
@@ -261,8 +265,11 @@ static int process_root(int argc, char *argv[])
char *old_passwd = NULL;
char *remote_machine = NULL;
- while ((ch = getopt(argc, argv, "ax:d:e:mnj:r:sR:D:U:")) != EOF) {
+ while ((ch = getopt(argc, argv, "ax:d:e:mnj:r:sR:D:U:L")) != EOF) {
switch(ch) {
+ case 'L':
+ local_mode = True;
+ break;
case 'a':
local_flags |= LOCAL_ADD_USER;
break;
@@ -609,7 +616,14 @@ int main(int argc, char **argv)
exit(1);
}
- if (getuid() == 0) {
+ /* pre-check for local mode option as first option. We can't
+ do this via normal getopt as getopt can't be called
+ twice. */
+ if (argc > 1 && strcmp(argv[1], "-L") == 0) {
+ local_mode = True;
+ }
+
+ if (local_mode || getuid() == 0) {
return process_root(argc, argv);
}