1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

added a -L option to smbpasswd to force it to run locally so we can test smbpasswd as non-root

This commit is contained in:
Andrew Tridgell
-
parent 55109a7525
commit ab63520265

View File

@ -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);
}