Sync up with appliance-head printer and other changes. Makes merges easier.
authorJeremy Allison <jra@samba.org>
Fri, 12 Jan 2001 19:28:03 +0000 (19:28 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 12 Jan 2001 19:28:03 +0000 (19:28 +0000)
Jeremy.

19 files changed:
source/include/proto.h
source/lib/cmd_interp.c
source/lib/messages.c
source/lib/username.c
source/libsmb/cli_lsarpc.c
source/nsswitch/winbindd_cache.c
source/nsswitch/winbindd_idmap.c
source/nsswitch/wins.c
source/passdb/secrets.c
source/passdb/tdbpass.c
source/printing/nt_printing.c
source/printing/printing.c
source/rpc_parse/parse_sec.c
source/rpc_server/srv_spoolss_nt.c
source/script/installbin.sh
source/script/makeyodldocs.sh
source/smbd/connection.c
source/smbd/uid.c
source/utils/smbpasswd.c

index b402106829d5dacbfdc0f9ddee37905fd029ba50..78f7cafc944b056f48ad77aa0fc005344f4f8dcc 100644 (file)
@@ -46,8 +46,7 @@ void add_char_string(char *s);
 /*The following definitions come from  lib/cmd_interp.c  */
 
 void free_cmd_set_array(uint32 num_entries, struct command_set **entries);
-struct command_set *add_cmd_set_to_array(uint32 *len,
-                                        struct command_set ***array,
+struct command_set *add_cmd_set_to_array(uint32 *len, struct command_set ***array,
                                         const struct command_set *cmd);
 void add_command_set(const struct command_set *cmds);
 void cmd_set_no_autoconnect(void);
@@ -634,17 +633,20 @@ struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
                                     struct ntuser_creds *creds);
 void cli_lsa_shutdown(struct cli_state *cli);
 uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, 
-                          uint32 des_access, POLICY_HND *hnd);
-uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *hnd);
-uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *hnd,
+                          uint32 des_access, POLICY_HND *pol);
+uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol);
+uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
                           int num_sids, DOM_SID *sids, char ***names, 
                           uint32 **types, int *num_names);
-uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *hnd,
+uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
                            int num_names, char **names, DOM_SID **sids,
                            uint32 **types, int *num_sids);
-uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *hnd
+uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol
                                 uint16 info_class, fstring domain_name, 
                                 DOM_SID * domain_sid);
+uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, 
+                             uint32 *enum_ctx, uint32 *num_domains,
+                             char ***domain_names, DOM_SID **domain_sids);
 
 /*The following definitions come from  libsmb/cliconnect.c  */
 
index 8951db10cfa9537ebede4ffc3f50876f7e9ab694..7d40a381361b8a276598424a6c6f54c7ce5672ba 100644 (file)
@@ -2,7 +2,9 @@
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB client
-   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) Andrew Tridgell               1994-1998
+   Copyright (C) Luke Kenneth Casson Leighton  1998-2000
+   Copyright (C) Gerald Carter                      2000
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -65,9 +67,8 @@ FILE *out_hnd;
 static void cmd_set_free(struct command_set *item)
 {
        if (item != NULL)
-       {
                safe_free(item->name);
-       }
+
        safe_free(item);
 }
 
@@ -75,16 +76,14 @@ static struct command_set *cmd_set_dup(const struct command_set *from)
 {
        if (from != NULL)
        {
-               struct command_set *copy =
-                       (struct command_set
-                        *)malloc(sizeof(struct command_set));
+               struct command_set *copy;
+               
+               copy = (struct command_set*)malloc(sizeof(struct command_set));
                if (copy != NULL)
                {
                        memcpy(copy, from, sizeof(struct command_set));
                        if (from->name != NULL)
-                       {
                                copy->name = strdup(from->name);
-                       }
                }
                return copy;
        }
@@ -97,13 +96,11 @@ void free_cmd_set_array(uint32 num_entries, struct command_set **entries)
        free_void_array(num_entries, (void **)entries, *fn);
 }
 
-struct command_set *add_cmd_set_to_array(uint32 *len,
-                                        struct command_set ***array,
+struct command_set *add_cmd_set_to_array(uint32 *len, struct command_set ***array,
                                         const struct command_set *cmd)
 {
        void *(*fn) (const void *) = (void *(*)(const void *))&cmd_set_dup;
-       return (struct command_set *)add_copy_to_array(len,
-                                                      (void ***)array,
+       return (struct command_set *)add_copy_to_array(len, (void ***)array,
                                                       (const void *)cmd, *fn,
                                                       False);
 
@@ -214,6 +211,7 @@ static uint32 cmd_quit(struct client_info *info, int argc, char *argv[])
 
        free_connections();
        exit(0);
+       
        /* NOTREACHED */
        return 0;
 }
@@ -226,12 +224,12 @@ static uint32 cmd_help(struct client_info *info, int argc, char *argv[])
        int i = 0;
 
        /* get help on a specific command */
-       if (argc > 0)
+       if (argc > 1)
        {
-               if ((i = process_tok(argv[1])) >= 0)
+               if ((i = process_tok(argv[0])) >= 0)
                {
-                       fprintf(out_hnd, "HELP %s:\n\t%s\n\n",
-                               commands[i]->name, commands[i]->description);
+                       fprintf(out_hnd, "HELP %s:\n\t%s\n\n", commands[i]->name, 
+                               commands[i]->description);
                }
 
                return 0;
@@ -296,9 +294,7 @@ static BOOL get_cmd_args(char *line)
 
        /* get the first part of the command */
        if (!next_token(&ptr, tok, NULL, sizeof(tok)))
-       {
                return False;
-       }
 
        do
        {
@@ -326,14 +322,12 @@ static uint32 do_command(struct client_info *info, char *line)
                return False;
 
        if (cmd_argc == 0)
-       {
                return False;
-       }
        
        i = process_tok(cmd_argv[0]);
        if (i >= 0)
        {
-               int argc = ((int)cmd_argc)-1;
+               int argc = ((int)cmd_argc);
                char **argv = cmd_argv;
                optind = 0;
 
@@ -539,9 +533,7 @@ static char *complete_cmd(char *text, int state)
        /* Initialise */
 
        if (state == 0)
-       {
                cmd_index = 0;
-       }
 
        /* Return the next name which partially matches the list of commands */
 
@@ -549,9 +541,7 @@ static char *complete_cmd(char *text, int state)
               && (strlen(name = commands[cmd_index++]->name) > 0))
        {
                if (strncmp(name, text, strlen(text)) == 0)
-               {
                        return strdup(name);
-               }
        }
 
        return NULL;
@@ -576,9 +566,7 @@ static char **completion_fn(char *text, int start, int end)
        /* Complete rpcclient command */
 
        if (start == 0)
-       {
                return completion_matches(text, complete_cmd);
-       }
 
        /* Count # of words in command */
 
@@ -586,9 +574,7 @@ static char **completion_fn(char *text, int start, int end)
        for (i = 0; i <= end; i++)
        {
                if ((rl_line_buffer[i] != ' ') && (lastch == ' '))
-               {
                        num_words++;
-               }
                lastch = rl_line_buffer[i];
        }
 
@@ -605,25 +591,19 @@ static char **completion_fn(char *text, int start, int end)
                if (strncmp(rl_line_buffer, commands[cmd_index]->name,
                            strlen(commands[cmd_index]->name)) == 0)
                {
-
                        /* Call appropriate completion function */
 
                        if (num_words == 2 || num_words == 3)
                        {
                                char *(*fn) (char *, int);
-                               fn =
-                                       commands[cmd_index]->compl_args
-                                       [num_words - 2];
+                               fn = commands[cmd_index]->compl_args[num_words - 2];
                                if (fn != NULL)
-                               {
                                        return completion_matches(text, fn);
-                               }
                        }
                }
        }
 
        /* Eeek! */
-
        return NULL;
 }
 
@@ -680,13 +660,9 @@ static uint32 cmd_use(struct client_info *info, int argc, char *argv[])
 
 
        if (usr_creds != NULL)
-       {
                copy_nt_creds(&usr.ntc, &usr_creds->ntc);
-       }
        else
-       {
                copy_nt_creds(&usr.ntc, NULL);
-       }
 
        pstrcpy(dest_host, cli_info.dest_host);
        pstrcpy(usr.ntc.user_name, optarg);
@@ -805,15 +781,10 @@ static uint32 cmd_use(struct client_info *info, int argc, char *argv[])
                        {
                                if (use[i] != NULL && use[i]->connected)
                                {
-                                       report(out_hnd, "Server:\t%s\t",
-                                              use[i]->srv_name);
-                                       report(out_hnd, "Key:\t[%d,%x]\t",
-                                              use[i]->key.pid,
-                                              use[i]->key.vuid);
-                                       report(out_hnd, "User:\t%s\t",
-                                              use[i]->user_name);
-                                       report(out_hnd, "Domain:\t%s\n",
-                                              use[i]->domain);
+                                       report(out_hnd, "Server:\t%s\t",use[i]->srv_name);
+                                       report(out_hnd, "Key:\t[%d,%x]\t",use[i]->key.pid, use[i]->key.vuid);
+                                       report(out_hnd, "User:\t%s\t", use[i]->user_name);
+                                       report(out_hnd, "Domain:\t%s\n", use[i]->domain);
                                }
                        }
                }
@@ -822,13 +793,9 @@ static uint32 cmd_use(struct client_info *info, int argc, char *argv[])
        {
                BOOL isnew;
                if (null_pwd)
-               {
                        set_user_password(&usr.ntc, True, NULL);
-               }
                else
-               {
                        set_user_password(&usr.ntc, got_pwd, password);
-               }
 
                /* paranoia: destroy the local copy of the password */
                ZERO_STRUCT(password);
@@ -837,15 +804,10 @@ static uint32 cmd_use(struct client_info *info, int argc, char *argv[])
                       srv_name, usr.ntc.user_name, usr.ntc.domain);
                report(out_hnd, "Connection:\t");
 
-               if (cli_net_use_add(srv_name, &usr.ntc, 
-                                   info->reuse, &isnew) != NULL)
-               {
+               if (cli_net_use_add(srv_name, &usr.ntc, info->reuse, &isnew) != NULL)
                        report(out_hnd, "OK\n");
-               }
                else
-               {
                        report(out_hnd, "FAILED\n");
-               }
        }
        else
        {
@@ -854,23 +816,14 @@ static uint32 cmd_use(struct client_info *info, int argc, char *argv[])
                       srv_name, usr.ntc.user_name, usr.ntc.domain);
                report(out_hnd, "Connection:\t");
 
-               if (!cli_net_use_del(srv_name, &usr.ntc,
-                                    force_close, &closed))
-               {
+               if (!cli_net_use_del(srv_name, &usr.ntc, force_close, &closed))
                        report(out_hnd, ": Does not exist\n");
-               }
                else if (force_close && closed)
-               {
                        report(out_hnd, ": Forcibly terminated\n");
-               }
                else if (closed)
-               {
                        report(out_hnd, ": Terminated\n");
-               }
                else
-               {
                        report(out_hnd, ": Unlinked\n");
-               }
        }
 
        /* paranoia: destroy the local copy of the password */
@@ -909,7 +862,68 @@ void cmd_set_no_autoconnect(void)
 #define CMD_SCOPE 0x10000
 #define CMD_INTER 0x20000
 
-static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
+static void read_authfile (char *filename, char* username, char* password)
+{
+       FILE *auth;
+        fstring buf;
+        uint16 len = 0;
+       char *ptr, *val, *param;
+                               
+       if ((auth=sys_fopen(filename, "r")) == NULL)
+       {
+               /* fail if we can't open the credentials file */
+               DEBUG(0,("ERROR: Unable to open credentials file!\n"));
+               return;
+       }
+                                
+       while (!feof(auth))
+       {  
+               /* get a line from the file */
+               if (!fgets (buf, sizeof(buf), auth))
+                       continue;
+               
+               len = strlen(buf);
+               
+               /* skip empty lines */                  
+               if ((len) && (buf[len-1]=='\n'))
+               {
+                       buf[len-1] = '\0';
+                       len--;
+               }       
+               if (len == 0)
+                       continue;
+                                       
+               /* break up the line into parameter & value.
+                  will need to eat a little whitespace possibly */
+               param = buf;
+               if (!(ptr = strchr (buf, '=')))
+                       continue;
+               val = ptr+1;
+               *ptr = '\0';
+                                       
+               /* eat leading white space */
+               while ((*val!='\0') && ((*val==' ') || (*val=='\t')))
+                       val++;
+                                       
+               if (strwicmp("password", param) == 0)
+               {
+                       pstrcpy(password, val);
+                       cmd_set_options |= CMD_PASS;
+               }
+               else if (strwicmp("username", param) == 0)
+               {
+                       pstrcpy(username, val);
+                       cmd_set_options |= CMD_USER;
+               }
+                                               
+               memset(buf, 0, sizeof(buf));
+       }
+       fclose(auth);
+       
+       return;
+}
+
+static uint32 cmd_set(CLIENT_INFO *info, int argc, char *argv[])
 {
        BOOL interactive = True;
        char *cmd_str = NULL;
@@ -920,6 +934,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
        pstring term_code;
        pstring password;       /* local copy only, if one is entered */
        fstring srv_name;
+       int new_debuglevel = -1;
 
        password[0] = 0;
        usr_creds = &usr;
@@ -942,6 +957,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                argc--;
                argv++;
        }
+       
        if (argc > 1 && (*argv[1] != '-'))
        {
                cmd_set_options |= CMD_PASS;
@@ -951,31 +967,29 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                argv++;
        }
 
-       while ((opt = getopt(argc, argv,
-                            "PRs:O:M:S:i:Nn:d:l:hI:EB:U:L:t:m:W:T:D:c:A:")) !=
-              EOF)
+       while ((opt = getopt(argc, argv,"PRs:O:M:S:i:Nn:d:l:hI:EB:U:L:t:m:W:T:D:c:A:")) != EOF)
        {
                switch (opt)
                {
+                       /* reuse connections in the case of a previous authentication */
                        case 'R':
                        {
                                info->reuse = True;
                                break;
                        }
 
+                       /* max protocol */
                        case 'm':
                        {
                                /* FIXME ... max_protocol seems to be funny here */
 
                                int max_protocol = 0;
-                               max_protocol =
-                                       interpret_protocol(optarg,
-                                                          max_protocol);
-                               fprintf(stderr,
-                                       "max protocol not currently supported\n");
+                               max_protocol = interpret_protocol(optarg, max_protocol);
+                               fprintf(stderr, "max protocol not currently supported\n");
                                break;
                        }
 
+                       /* socket options */
                        case 'O':
                        {
                                cmd_set_options |= CMD_SOCK;
@@ -983,6 +997,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* define the server to connect to */
                        case 'S':
                        {
                                cmd_set_options |= CMD_HOST;
@@ -991,6 +1006,8 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* username for the connection -- support the 
+                          username%password format as well */
                        case 'U':
                        {
                                char *lp;
@@ -1005,64 +1022,15 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                }
                                break;
                        }
+                       
+                       /* authfile -- only get the username and password from the file */
                        case 'A':
                        {
-                               FILE *auth;
-                               fstring buf;
-                               uint16 len = 0;
-                               char *ptr, *val, *param;
-                               
-                               if ((auth=sys_fopen(optarg, "r")) == NULL)
-                               {
-                                       /* fail if we can't open the credentials file */
-                                       DEBUG(0,("ERROR: Unable to open credentials file!\n"));
-                                       exit (-1);
-                               }
-                                
-                               while (!feof(auth))
-                               {  
-                                       /* get a line from the file */
-                                       if (!fgets (buf, sizeof(buf), auth))
-                                               continue;
-                                       len = strlen(buf);
-                                       
-                                       if ((len) && (buf[len-1]=='\n'))
-                                       {
-                                               buf[len-1] = '\0';
-                                               len--;
-                                       }       
-                                       if (len == 0)
-                                               continue;
-                                       
-                                       /* break up the line into parameter & value.
-                                          will need to eat a little whitespace possibly */
-                                       param = buf;
-                                       if (!(ptr = strchr (buf, '=')))
-                                               continue;
-                                       val = ptr+1;
-                                       *ptr = '\0';
-                                       
-                                       /* eat leading white space */
-                                       while ((*val!='\0') && ((*val==' ') || (*val=='\t')))
-                                               val++;
-                                       
-                                       if (strwicmp("password", param) == 0)
-                                       {
-                                               pstrcpy(password, val);
-                                               cmd_set_options |= CMD_PASS;
-                                       }
-                                       else if (strwicmp("username", param) == 0)
-                                       {
-                                               pstrcpy(usr.ntc.user_name, val);
-                                               cmd_set_options |= CMD_USER;
-                                       }
-                                               
-                                       memset(buf, 0, sizeof(buf));
-                               }
-                               fclose(auth);
+                               read_authfile (optarg, usr.ntc.user_name, password);
                                break;
                        }
 
+                       /* define the workgroup/domain name */
                        case 'W':
                        {
                                cmd_set_options |= CMD_DOM;
@@ -1070,12 +1038,14 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
                        
+                       /* should we display a command prompt at all */
                        case 'P':
                        { /* optarg == prompt string ? */
                                info->show_prompt = False;
                                break;
                        }
 
+                       /* send to stderr instaed of stdout */
                        case 'E':
                        {
                                cmd_set_options |= CMD_DBG;
@@ -1083,6 +1053,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* IP address of destination host */
                        case 'I':
                        {
                                cmd_set_options |= CMD_IP;
@@ -1095,6 +1066,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* define netbios name of client machine we are on */
                        case 'n':
                        {
                                cmd_set_options |= CMD_NAME;
@@ -1102,31 +1074,35 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* do not prompt for a password.  Implies anonymous connection
+                          unless the password was passed in username%password form */
                        case 'N':
                        {
                                cmd_set_options |= CMD_NOPW | CMD_PASS;
                                break;
                        }
 
+                       /* debug level */
                        case 'd':
                        {
                                cmd_set_options |= CMD_DBLV;
                                if (*optarg == 'A')
-                                       DEBUGLEVEL = 10000;
+                                       new_debuglevel = 10000;
                                else
-                                       DEBUGLEVEL = atoi(optarg);
+                                       new_debuglevel = atoi(optarg);
                                break;
                        }
 
+                       /* log file name */
                        case 'l':
                        {
                                cmd_set_options |= CMD_INTER;
-                               slprintf(debugf, sizeof(debugf) - 1,
-                                        "%s.client", optarg);
+                               slprintf(debugf, sizeof(debugf) - 1, "%s.client", optarg);
                                interactive = False;
                                break;
                        }
 
+                       /* command string to be executed */
                        case 'c':
                        {
                                cmd_set_options |= CMD_STR;
@@ -1134,6 +1110,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* program usage/help screen */
                        case 'h':
                        {
                                cmd_set_options |= CMD_HELP;
@@ -1141,6 +1118,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* config file to use */
                        case 's':
                        {
                                cmd_set_options |= CMD_SVC;
@@ -1148,6 +1126,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                                break;
                        }
 
+                       /* terminal code */
                        case 't':
                        {
                                cmd_set_options |= CMD_TERM;
@@ -1164,7 +1143,9 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                }
        }
 
-       if (cmd_set_options & CMD_INTER) {
+       
+       if (cmd_set_options & CMD_INTER)
+       {
                setup_logging(debugf, interactive);
                if (!interactive)
                        reopen_logs();
@@ -1173,17 +1154,22 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
        strupper(global_myname);
        fstrcpy(cli_info.myhostname, global_myname);
 
-       if (cmd_set_options & CMD_SVC) {
+       if (cmd_set_options & CMD_SVC) 
+       {
                if (!lp_load(servicesf, True, False, False))
                {
-                       fprintf(stderr,
-                               "Can't load %s - run testparm to debug it\n",
+                       fprintf(stderr, "Can't load %s - run testparm to debug it\n",
                                servicesf);
                }
 
        }
 
-       if (cmd_set_options & CMD_INTER) {
+       if (new_debuglevel != -1) {
+               DEBUGLEVEL = new_debuglevel;
+       }
+
+       if (cmd_set_options & CMD_INTER) 
+       {
                load_interfaces();
        }
 
@@ -1194,20 +1180,16 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
        }
 
        /* NULL password if specified or is username is empty */
-       if ((cmd_set_options & CMD_NOPW) || (strlen(usr.ntc.user_name) == 0)) {
+       if ((cmd_set_options & CMD_NOPW) || (strlen(usr.ntc.user_name) == 0)) 
                set_user_password(&usr.ntc, True, NULL);
-       }
        else
-       {
-               set_user_password(&usr.ntc,
-                                 ((cmd_set_options & CMD_PASS) != 0),
-                                 password);
-       }
+               set_user_password(&usr.ntc, ((cmd_set_options & CMD_PASS) != 0), password);
 
        /* paranoia: destroy the local copy of the password */
        ZERO_STRUCT(password);
 
-       if (strcmp(cli_info.dest_host, "*") == 0) {
+       if (strcmp(cli_info.dest_host, "*") == 0) 
+       {
                /* special case - we want the PDC */
                struct in_addr ip;
                if (!resolve_srv_name(cli_info.dest_host, cli_info.dest_host, &ip)) {
@@ -1221,7 +1203,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
        strupper(srv_name);
 
 
-       if (auto_connect && !strequal(srv_name, "\\\\."))
+       if (auto_connect)
        {
                BOOL isnew;
                report(out_hnd, "Server:\t%s:\tUser:\t%s\tDomain:\t%s\n",
@@ -1239,10 +1221,9 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[])
                /* ???? --jerry
                usr_creds = NULL; */
        }
+       
        if (cmd_str != NULL)
-       {
                return process(&cli_info, cmd_str);
-       }
 
        return 0;
 }
@@ -1268,21 +1249,15 @@ static void read_user_env(struct ntuser_creds *u)
                        memset(strchr(getenv("USER"), '%') + 1, 'X',
                               strlen(password));
                }
-               strupper(u->user_name);
        }
 
        /* modification to support PASSWD environmental var
           25.Aug.97, jdblair@uab.edu */
        if (getenv("PASSWD"))
-       {
                pstrcpy(password, getenv("PASSWD"));
-       }
 
        if (*u->user_name == 0 && getenv("LOGNAME"))
-       {
                pstrcpy(u->user_name, getenv("LOGNAME"));
-               strupper(u->user_name);
-       }
 
        set_user_password(u, True, password);
 
@@ -1320,15 +1295,21 @@ int command_main(int argc, char *argv[])
        DEBUGLEVEL = 2;
 
        charset_initialise();
+
+       /* add in the internal command set and the various
+          client RPC groups--spoolss, lsa, etc... */
        add_command_set(general_commands);
 
+       /* usr_creds is a global most recently used set of user credentials
+          retrieved from the connection list. */
        copy_user_creds(&usr, NULL);
-
        usr_creds = &usr;
        usr.ptr_ntc = 1;
-
+       
        out_hnd = stdout;
 
+       /* retrieve the binary name used when invoking the program
+          for instances like samedit, etc... */
        strncpy(path, argv[0], 255);
        for (s = strtok(path, "/"); s; s = strtok(NULL, "/"))
                fstrcpy(progname, s);
@@ -1336,15 +1317,15 @@ int command_main(int argc, char *argv[])
        slprintf(debugf, sizeof(debugf) - 1,
                 "%s/log.%s", LOGFILEBASE, progname);
 
+       /* initialize usr */
        pstrcpy(usr.ntc.domain, "");
        pstrcpy(usr.ntc.user_name, "");
-
        pstrcpy(cli_info.myhostname, "");
        pstrcpy(cli_info.dest_host, "");
-       cli_info.dest_ip.s_addr = 0;
        
+       /* init client_info struct */
+       cli_info.dest_ip.s_addr = 0;
        cli_info.show_prompt = True;
-
        ZERO_STRUCT(cli_info.dom.level3_sid);
        ZERO_STRUCT(cli_info.dom.level5_sid);
        fstrcpy(cli_info.dom.level3_dom, "");
@@ -1379,8 +1360,12 @@ int command_main(int argc, char *argv[])
 
        codepage_initialise(lp_client_code_page());
 
+       /*  parse the command line args
+           init the first connection if possible
+           process a command if passed in on the command line */
        status = cmd_set(&cli_info, argc, argv);
 
+       /* Should we exit?  Are we done? */
        if (cmd_set_options & (CMD_HELP|CMD_STR)) {
                free_connections();
                get_safe_nt_error_msg(status, msg, sizeof(msg));
@@ -1393,16 +1378,17 @@ int command_main(int argc, char *argv[])
        DEBUG(3, ("%s client started (version %s)\n",
                  timestring(False), VERSION));
 
+       /* enter shell mode */
        status = process(&cli_info, NULL);
 
+       /* cleanup */
        free_connections();
-
        free_cmd_set_array(num_commands, commands);
        num_commands = 0;
        commands = NULL;
        
+       /* report and exit */
        get_safe_nt_error_msg(status, msg, sizeof(msg));
        report(out_hnd, "Exit Status: %s\n", msg);
-
        return status;
 }
index bc6f20993810a9fa6723e430e621becbe39ffc55..f856f50b9900352f6931cb5ddab865685dfce3b8 100644 (file)
@@ -161,8 +161,8 @@ BOOL message_send_pid(pid_t pid, int msg_type, void *buf, size_t len, BOOL dupli
         */
 
        if (!process_exists(pid)) {
-               tdb_delete(tdb, message_key_pid(pid));
                DEBUG(2,("message_send_pid: pid %d doesn't exist\n", (int)pid));
+        tdb_delete(tdb, message_key_pid(pid));
                return False;
        }
 
index fbc9c7c44b82d24e34f34028d1cbba91556bbc9d..7ba7b647e930904cff320aea8168f59161e0b06f 100644 (file)
@@ -176,10 +176,11 @@ static struct passwd *_Get_Pwnam(char *s)
     - using the lp_usernamelevel() for permutations
  Note that this can change user!
 ****************************************************************************/
+
 struct passwd *Get_Pwnam(char *user,BOOL allow_change)
 {
        fstring         user2, orig_username;
-       int             usernamelevel = lp_usernamelevel();
+       int             usernamelevel = lp_usernamelevel();
        struct          passwd *ret;  
 
        if (!user || !(*user))
index 3651d786efcd1901bd03650d8d7292916e4afe80..e4da7a7cc7e151d7b2471a70bdbdb256cb81a568 100644 (file)
@@ -38,8 +38,6 @@ struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
 
        /* Initialise cli_state information */
 
-       ZERO_STRUCTP(cli);
-
        if (!cli_initialise(cli)) {
                return NULL;
        }
@@ -87,7 +85,7 @@ void cli_lsa_shutdown(struct cli_state *cli)
 /* Open a LSA policy handle */
 
 uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos, 
-                          uint32 des_access, POLICY_HND *hnd)
+                          uint32 des_access, POLICY_HND *pol)
 {
        prs_struct qbuf, rbuf;
        LSA_Q_OPEN_POL q;
@@ -127,12 +125,10 @@ uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos,
                goto done;
        }
 
-       result = r.status;
-
        /* Return output parameters */
 
-       if (result == NT_STATUS_NOPROBLEMO) {
-               *hnd = r.pol;
+       if ((result = r.status) == NT_STATUS_NOPROBLEMO) {
+               *pol = r.pol;
        }
 
  done:
@@ -144,7 +140,7 @@ uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos,
 
 /* Close a LSA policy handle */
 
-uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
+uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol)
 {
        prs_struct qbuf, rbuf;
        LSA_Q_CLOSE q;
@@ -161,7 +157,7 @@ uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
 
        /* Marshall data and send request */
 
-       init_lsa_q_close(&q, hnd);
+       init_lsa_q_close(&q, pol);
 
        if (!lsa_io_q_close("", &q, &qbuf, 0) ||
            !rpc_api_pipe_req(cli, LSA_CLOSE, &qbuf, &rbuf)) {
@@ -176,12 +172,10 @@ uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
                goto done;
        }
 
-       result = r.status;
-
        /* Return output parameters */
 
-       if (result == NT_STATUS_NOPROBLEMO) {
-               *hnd = r.pol;
+       if ((result = r.status) == NT_STATUS_NOPROBLEMO) {
+               *pol = r.pol;
        }
 
  done:
@@ -193,7 +187,7 @@ uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
 
 /* Lookup a list of sids */
 
-uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *hnd,
+uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
                           int num_sids, DOM_SID *sids, char ***names, 
                           uint32 **types, int *num_names)
 {
@@ -215,7 +209,7 @@ uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *hnd,
 
        /* Marshall data and send request */
 
-       init_q_lookup_sids(cli->mem_ctx, &q, hnd, num_sids, sids, 1);
+       init_q_lookup_sids(cli->mem_ctx, &q, pol, num_sids, sids, 1);
 
        if (!lsa_io_q_lookup_sids("", &q, &qbuf, 0) ||
            !rpc_api_pipe_req(cli, LSA_LOOKUPSIDS, &qbuf, &rbuf)) {
@@ -238,8 +232,8 @@ uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *hnd,
 
        result = r.status;
 
-       if (result != 0 && r.status != 0x107 &&
-           r.status != (0xC0000000 | NT_STATUS_NONE_MAPPED)) {
+       if (result != NT_STATUS_NOPROBLEMO && result != 0x00000107 &&
+           result != (0xC0000000 | NT_STATUS_NONE_MAPPED)) {
                
                /* An actual error occured */
 
@@ -300,7 +294,7 @@ uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *hnd,
 
 /* Lookup a list of names */
 
-uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *hnd,
+uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
                            int num_names, char **names, DOM_SID **sids,
                            uint32 **types, int *num_sids)
 {
@@ -321,7 +315,7 @@ uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *hnd,
 
        /* Marshall data and send request */
 
-       init_q_lookup_names(cli->mem_ctx, &q, hnd, num_names, names);
+       init_q_lookup_names(cli->mem_ctx, &q, pol, num_names, names);
 
        if (!lsa_io_q_lookup_names("", &q, &qbuf, 0) ||
            !rpc_api_pipe_req(cli, LSA_LOOKUPNAMES, &qbuf, &rbuf)) {
@@ -341,7 +335,8 @@ uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *hnd,
 
        result = r.status;
 
-       if (result != 0 && result != (0xC0000000 | NT_STATUS_NONE_MAPPED)) {
+       if (result != NT_STATUS_NOPROBLEMO && 
+           result != (0xC0000000 | NT_STATUS_NONE_MAPPED)) {
 
                /* An actual error occured */
 
@@ -400,7 +395,7 @@ uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *hnd,
 
 /* Query info policy */
 
-uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *hnd
+uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol
                                 uint16 info_class, fstring domain_name, 
                                 DOM_SID * domain_sid)
 {
@@ -419,7 +414,7 @@ uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *hnd,
 
        /* Marshall data and send request */
 
-       init_q_query(&q, hnd, info_class);
+       init_q_query(&q, pol, info_class);
 
        if (!lsa_io_q_query("", &q, &qbuf, 0) ||
            !rpc_api_pipe_req(cli, LSA_QUERYINFOPOLICY, &qbuf, &rbuf)) {
@@ -434,9 +429,7 @@ uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *hnd,
                goto done;
        }
 
-       result = r.status;
-
-       if (result != NT_STATUS_NOPROBLEMO) {
+       if ((result = r.status) != NT_STATUS_NOPROBLEMO) {
                goto done;
        }
 
@@ -483,3 +476,87 @@ uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *hnd,
 
        return result;
 }
+
+/* Enumerate list of trusted domains */
+
+uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, 
+                             uint32 *enum_ctx, uint32 *num_domains,
+                             char ***domain_names, DOM_SID **domain_sids)
+{
+       prs_struct qbuf, rbuf;
+       LSA_Q_ENUM_TRUST_DOM q;
+       LSA_R_ENUM_TRUST_DOM r;
+       uint32 result;
+       int i;
+
+       ZERO_STRUCT(q);
+       ZERO_STRUCT(r);
+
+       /* Initialise parse structures */
+
+       prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
+       prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+
+       /* Marshall data and send request */
+
+        init_q_enum_trust_dom(&q, pol, *enum_ctx, 0xffffffff);
+
+       if (!lsa_io_q_enum_trust_dom("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, LSA_ENUMTRUSTDOM, &qbuf, &rbuf)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       /* Unmarshall response */
+
+       if (!lsa_io_r_enum_trust_dom("", &r, &rbuf, 0)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       result = r.status;
+
+       if (result != NT_STATUS_NOPROBLEMO && result != 0x8000001a) {
+
+               /* An actual error ocured */
+
+               goto done;
+       }
+
+       result = NT_STATUS_NOPROBLEMO;
+
+       /* Return output parameters */
+
+       if (!((*domain_names) = (char **)malloc(sizeof(char *) *
+                                               r.num_domains))) {
+               DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n"));
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       if (!((*domain_sids) = (DOM_SID *)malloc(sizeof(DOM_SID) *
+                                                r.num_domains))) {
+               DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n"));
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       for (i = 0; i < r.num_domains; i++) {
+               fstring tmp;
+
+               unistr2_to_ascii(tmp, &r.uni_domain_name[i], sizeof(tmp) - 1);
+               (*domain_names)[i] = strdup(tmp);
+               sid_copy(&(*domain_sids)[i], &r.domain_sid[i].sid);
+       }
+
+       *num_domains = r.num_domains;
+       *enum_ctx = r.enum_context;
+
+       lsa_free_r_enum_trust_dom(&r);
+
+ done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;
+}
index cd648c696c7d13c76e644a10ba849a5d5449fc59..226a96b9b50003026db9aca14de9df903be83cb7 100644 (file)
@@ -56,6 +56,7 @@ static uint32 cached_sequence_number(char *domain_name)
        time_t t = time(NULL);
 
        slprintf(keystr, sizeof(keystr), "CACHESEQ/%s", domain_name);
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        dbuf = tdb_fetch_by_string(cache_tdb, keystr);
        if (!dbuf.dptr || dbuf.dsize != sizeof(rec)) {
                goto refetch;
@@ -92,6 +93,7 @@ static void set_cache_sequence_number(char *domain_name, char *cache_type, char
        fstring keystr;
        slprintf(keystr,sizeof(keystr),"CACHESEQ %s/%s/%s",
                 domain_name, cache_type, subkey?subkey:"");
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        tdb_store_int(cache_tdb, keystr, cached_sequence_number(domain_name));
 }
 
@@ -101,6 +103,7 @@ static uint32 get_cache_sequence_number(char *domain_name, char *cache_type, cha
        uint32 seq_num;
        slprintf(keystr,sizeof(keystr),"CACHESEQ %s/%s/%s",
                 domain_name, cache_type, subkey?subkey:"");
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        seq_num = (uint32)tdb_fetch_int(cache_tdb, keystr);
        DEBUG(4,("%s is %u\n", keystr, (unsigned)seq_num));
        return seq_num;
@@ -124,7 +127,7 @@ static void fill_cache(char *domain_name, char *cache_type,
        /* Store data as a mega-huge chunk in the tdb */
        slprintf(keystr, sizeof(keystr), "%s CACHE DATA/%s", cache_type,
                 domain_name);
-
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        tdb_store_by_string(cache_tdb, keystr, 
                            sam_entries, sizeof(struct acct_info) * num_sam_entries);
 
@@ -156,6 +159,7 @@ static void fill_cache_entry(char *domain, char *cache_type, char *name, void *b
 
        /* Create key for store */
        slprintf(keystr, sizeof(keystr), "%s/%s/%s", cache_type, domain, name);
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
 
        DEBUG(4, ("filling cache entry %s\n", keystr));
 
@@ -200,6 +204,7 @@ void winbindd_fill_group_cache_entry(char *domain, char *group_name,
 
         /* Fill extra data */
         slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, group_name);
+        dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
         tdb_store_by_string(cache_tdb, keystr, extra_data, extra_data_len);
 
        set_cache_sequence_number(domain, CACHE_TYPE_GROUP, group_name);
@@ -222,6 +227,7 @@ void winbindd_fill_gid_cache_entry(char *domain, gid_t gid,
 
         /* Fill extra data */
         slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, gidstr);
+        dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
         tdb_store_by_string(cache_tdb, keystr, extra_data, extra_data_len);
 
        set_cache_sequence_number(domain, CACHE_TYPE_GROUP, gidstr);
@@ -250,6 +256,7 @@ static BOOL fetch_cache(char *domain_name, char *cache_type,
         /* Create key */        
         slprintf(keystr, sizeof(keystr), "%s CACHE DATA/%s", cache_type,
                  domain_name);
+        dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
        
         /* Fetch cache information */
        data = tdb_fetch_by_string(cache_tdb, keystr);
@@ -298,6 +305,7 @@ static BOOL fetch_cache_entry(char *domain, char *cache_type, char *name, void *
     
        /* Create key for lookup */
        slprintf(keystr, sizeof(keystr), "%s/%s/%s", cache_type, domain, name);
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
     
        /* Look up cache entry */
        data = tdb_fetch_by_string(cache_tdb, keystr);
@@ -362,6 +370,7 @@ BOOL winbindd_fetch_group_cache_entry(char *domain_name, char *group,
        
         /* Fetch extra data */
         slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, group);
+        dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
         data = tdb_fetch_by_string(cache_tdb, keystr);
 
         if (!data.dptr) return False;
@@ -399,6 +408,7 @@ BOOL winbindd_fetch_gid_cache_entry(char *domain_name, gid_t gid,
 
         /* Fetch extra data */
         slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, gidstr);
+        dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
         data = tdb_fetch_by_string(cache_tdb, keystr);
         if (!data.dptr) return False;
 
index 15a9ac400963a5336c730050dc125451e12dda5e..ff0818c4565b17058e95446f3f8dcfe681d60e55 100644 (file)
@@ -78,6 +78,7 @@ static BOOL get_id_from_rid(char *domain_name, uint32 rid, int *id,
     /* Check if rid is present in database */
 
     slprintf(keystr, sizeof(keystr), "%s/%d", domain_name, rid);
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
     
     key.dptr = keystr;
     key.dsize = strlen(keystr) + 1;
index 6fbaedcdea1d2460fbe0e5d70ed61a9c35ae37bc..be76c2e54ee201307de2ea106b4fcf1562cac3c6 100644 (file)
@@ -36,7 +36,7 @@ struct in_addr *lookup_backend(const char *name, int *count)
        int fd;
        static int initialised;
        struct in_addr *ret;
-       char *p;
+       struct in_addr  p;
        int j;
 
        if (!initialised) {
@@ -63,9 +63,9 @@ struct in_addr *lookup_backend(const char *name, int *count)
  *             goto out;
  *     }
  */
-       p = lp_wins_server();
-       if (p && *p) {
-               ret = name_query(fd,name,0x20,False,True, *interpret_addr2(p), count);
+       p = wins_srv_ip();
+       if( !zero_ip(p) ) {
+               ret = name_query(fd,name,0x20,False,True, p, count);
                goto out;
        }
 
index bd1ca279290a7e585a2fe085a13afc3325b29150..7042cbc2d09633174b85f41a38a21838cb3b0269 100644 (file)
@@ -104,6 +104,7 @@ BOOL secrets_fetch_domain_sid(char *domain, DOM_SID *sid)
        size_t size;
 
        slprintf(key, sizeof(key), "%s/%s", SECRETS_DOMAIN_SID, domain);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
        dyn_sid = (DOM_SID *)secrets_fetch(key, &size);
 
        if (dyn_sid == NULL)
@@ -128,6 +129,7 @@ char *trust_keystr(char *domain)
 {
        static fstring keystr;
        slprintf(keystr,sizeof(keystr),"%s/%s", SECRETS_MACHINE_ACCT_PASS, domain);
+       dos_to_unix(keystr, True);         /* Convert key to unix-codepage */
        return keystr;
 }
 
index c3afced2d49e27d05e83aec85c1b5d93f83be7ad..8f24e9b471eca8c7a17789fb6213fd36e5848d81 100644 (file)
@@ -184,6 +184,7 @@ static BOOL del_samtdbpwd_entry(const char *name)
   }
   
   slprintf(keystr, sizeof(keystr), "USER_%s", name);
+  dos_to_unix(keystr, True);               /* Convert key to unix-codepage */
   key.dptr = keystr;
   key.dsize = strlen (keystr) + 1;
   if (tdb_delete(pwd_tdb, key) != TDB_SUCCESS)
@@ -289,6 +290,7 @@ static BOOL mod_samtdb21pwd_entry(struct sam_passwd* newpwd, BOOL override)
     memcpy (tdb_entry->strings + tdb_entry->munged_dial_offset, newpwd->munged_dial, munged_dial_len);
  
   slprintf(keystr, sizeof(keystr), "USER_%s", newpwd->smb_name);
+  dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
   key.dptr = keystr;
   key.dsize = strlen (keystr) + 1;
   
@@ -399,6 +401,7 @@ static BOOL add_samtdb21pwd_entry(struct sam_passwd *newpwd)
     memcpy (tdb_entry->strings + tdb_entry->munged_dial_offset, newpwd->munged_dial, munged_dial_len);
   
   slprintf(keystr, sizeof(keystr), "USER_%s", newpwd->smb_name);
+  dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
   key.dptr = keystr;
   key.dsize = strlen (keystr) + 1;
   
@@ -460,6 +463,7 @@ static struct sam_passwd *getsamtdb21pwnam(char *name)
   }
 
   slprintf(keystr, sizeof(keystr), "USER_%s", name);
+  dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
   key.dptr = keystr;
   key.dsize = strlen (keystr) + 1;
 
index 699ddc60b2c1c5a105bdea17378387a502c66a75..2572a98bdea495315df7d9fa91ddaece0b6511a5 100644 (file)
@@ -144,6 +144,7 @@ int write_ntforms(nt_forms_struct **list, int number)
                               (*list)[i].bottom);
                if (len > sizeof(buf)) break;
                slprintf(key, sizeof(key), "%s%s", FORMS_PREFIX, (*list)[i].name);
+        dos_to_unix(key, True);            /* Convert key to unix-codepage */
                kbuf.dsize = strlen(key)+1;
                kbuf.dptr = key;
                dbuf.dsize = len;
@@ -235,6 +236,7 @@ BOOL delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, uint32
        }
 
        slprintf(key, sizeof(key), "%s%s", FORMS_PREFIX, (*list)[n].name);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
        kbuf.dsize = strlen(key)+1;
        kbuf.dptr = key;
        if (tdb_delete(tdb, kbuf) != 0) {
@@ -1301,27 +1303,41 @@ static uint32 add_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver)
 
        slprintf(directory, sizeof(directory), "\\print$\\%s\\%d\\", architecture, driver->cversion);
 
-       
-       fstrcpy(temp_name, driver->driverpath);
-       slprintf(driver->driverpath, sizeof(driver->driverpath), "%s%s", directory, temp_name);
+    /* .inf files do not always list a file for each of the four standard files. 
+     * Don't prepend a path to a null filename, or client claims:
+     *   "The server on which the printer resides does not have a suitable 
+     *   <printer driver name> printer driver installed. Click OK if you 
+     *   wish to install the driver on your local machine."
+     */
+       if (strlen(driver->driverpath)) {
+       fstrcpy(temp_name, driver->driverpath);
+       slprintf(driver->driverpath, sizeof(driver->driverpath), "%s%s", directory, temp_name);
+    }
 
-       fstrcpy(temp_name, driver->datafile);
-       slprintf(driver->datafile, sizeof(driver->datafile), "%s%s", directory, temp_name);
+       if (strlen(driver->datafile)) {
+       fstrcpy(temp_name, driver->datafile);
+       slprintf(driver->datafile, sizeof(driver->datafile), "%s%s", directory, temp_name);
+    }
 
-       fstrcpy(temp_name, driver->configfile);
-       slprintf(driver->configfile, sizeof(driver->configfile), "%s%s", directory, temp_name);
+       if (strlen(driver->configfile)) {
+       fstrcpy(temp_name, driver->configfile);
+       slprintf(driver->configfile, sizeof(driver->configfile), "%s%s", directory, temp_name);
+    }
 
-       fstrcpy(temp_name, driver->helpfile);
-       slprintf(driver->helpfile, sizeof(driver->helpfile), "%s%s", directory, temp_name);
+       if (strlen(driver->helpfile)) {
+       fstrcpy(temp_name, driver->helpfile);
+       slprintf(driver->helpfile, sizeof(driver->helpfile), "%s%s", directory, temp_name);
+    }
 
        if (driver->dependentfiles) {
                for (i=0; *driver->dependentfiles[i]; i++) {
-                       fstrcpy(temp_name, driver->dependentfiles[i]);
-                       slprintf(driver->dependentfiles[i], sizeof(driver->dependentfiles[i]), "%s%s", directory, temp_name);
+            fstrcpy(temp_name, driver->dependentfiles[i]);
+            slprintf(driver->dependentfiles[i], sizeof(driver->dependentfiles[i]), "%s%s", directory, temp_name);
                }
        }
 
        slprintf(key, sizeof(key), "%s%s/%d/%s", DRIVERS_PREFIX, architecture, driver->cversion, driver->name);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
 
        DEBUG(5,("add_a_printer_driver_3: Adding driver with key %s\n", key ));
 
@@ -1685,8 +1701,8 @@ uint32 del_a_printer(char *sharename)
        pstring key;
        TDB_DATA kbuf;
 
-       slprintf(key, sizeof(key), "%s%s",
-                PRINTERS_PREFIX, sharename);
+       slprintf(key, sizeof(key), "%s%s", PRINTERS_PREFIX, sharename);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
 
        kbuf.dptr=key;
        kbuf.dsize=strlen(key)+1;
@@ -1768,8 +1784,8 @@ static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
        }
        
 
-       slprintf(key, sizeof(key), "%s%s",
-                PRINTERS_PREFIX, info->sharename);
+       slprintf(key, sizeof(key), "%s%s", PRINTERS_PREFIX, info->sharename);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
 
        kbuf.dptr = key;
        kbuf.dsize = strlen(key)+1;
@@ -2196,6 +2212,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
        ZERO_STRUCT(info);
 
        slprintf(key, sizeof(key), "%s%s", PRINTERS_PREFIX, sharename);
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
 
        kbuf.dptr = key;
        kbuf.dsize = strlen(key)+1;
index ad7f66fdac96b44b6202a8e9f0b5672513efc088..3f8c542ec7d57575ad8a0c996a0f34036f07da57 100644 (file)
@@ -169,8 +169,8 @@ static int print_run_command(int snum,char *command,
        pstring_sub(syscmd, "%p", p);
        standard_sub_snum(snum,syscmd);
 
-    /* Convert script args to unix-codepage */
-    dos_to_unix(syscmd, True);
+       /* Convert script args to unix-codepage */
+       dos_to_unix(syscmd, True);
        ret = smbrun(syscmd,outfile,False);
 
        DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
@@ -304,6 +304,7 @@ static void print_cache_flush(int snum)
 {
        fstring key;
        slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
        tdb_store_int(tdb, key, -1);
 }
 
@@ -324,8 +325,11 @@ static void print_queue_update(int snum)
        struct traverse_struct tstruct;
        fstring keystr, printer_name;
        TDB_DATA data, key;
+              
+       /* Convert printer name (i.e. share name) to unix-codepage for all of the 
+        * following tdb key generation */
        fstrcpy(printer_name, lp_servicename(snum));
+       dos_to_unix(printer_name, True);
        
        /*
         * Update the cache time FIRST ! Stops others doing this
@@ -428,7 +432,7 @@ static void print_queue_update(int snum)
 
        /* store the new queue status structure */
        slprintf(keystr, sizeof(keystr), "STATUS/%s", printer_name);
-       key.dptr = keystr;
+    key.dptr = keystr;
        key.dsize = strlen(keystr);
 
        status.qcount = qcount;
@@ -722,6 +726,7 @@ static BOOL print_cache_expired(int snum)
        time_t t2, t = time(NULL);
 
        slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
+       dos_to_unix(key, True);                /* Convert key to unix-codepage */
        t2 = tdb_fetch_int(tdb, key);
        if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
                DEBUG(3, ("print cache expired\n"));
@@ -741,6 +746,7 @@ static int get_queue_status(int snum, print_status_struct *status)
 
        ZERO_STRUCTP(status);
        slprintf(keystr, sizeof(keystr), "STATUS/%s", lp_servicename(snum));
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        key.dptr = keystr;
        key.dsize = strlen(keystr);
        data = tdb_fetch(tdb, key);
@@ -1065,6 +1071,7 @@ int print_queue_status(int snum,
         */
        ZERO_STRUCTP(status);
        slprintf(keystr, sizeof(keystr), "STATUS/%s", lp_servicename(snum));
+       dos_to_unix(keystr, True);             /* Convert key to unix-codepage */
        key.dptr = keystr;
        key.dsize = strlen(keystr);
        data = tdb_fetch(tdb, key);
@@ -1203,8 +1210,9 @@ BOOL print_queue_purge(struct current_user *user, int snum, int *errcode)
        int njobs, i;
 
        njobs = print_queue_status(snum, &queue, &status);
-       for (i=0;i<njobs;i++) {
-               if (print_access_check(user, snum, PRINTER_ACCESS_ADMINISTER)) {
+
+       if (print_access_check(user, snum, PRINTER_ACCESS_ADMINISTER)) {
+               for (i=0;i<njobs;i++) {
                        print_job_delete1(queue[i].job);
                }
        }
index e2ca2202e1647f0b8373daf2de467a1869bedf99..c2c8ad120c9848b136e7a74a959baf718cefcda7 100644 (file)
@@ -416,7 +416,7 @@ BOOL sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2)
        }
 
  done:
-       DEBUG(10, ("sec_equal(): secdescs are identical\n"));
+       DEBUG(10, ("sec_desc_equal(): secdescs are identical\n"));
        return True;
 }
 
index 155bda7cd51bb5e5b176e8662ac5f599fa6dd2f6..23f8ab15efb1ddfa9fc5a805a113aa3253def429 100644 (file)
@@ -2740,23 +2740,31 @@ static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst
  ********************************************************************/
 static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
 {
-       pstring temp_driverpath;
-       pstring temp_datafile;
-       pstring temp_configfile;
+       pstring temp;
 
        info->version=driver.info_3->cversion;
 
        init_unistr( &info->name, driver.info_3->name );
        init_unistr( &info->architecture, driver.info_3->environment );
 
-       snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath);
-       init_unistr( &info->driverpath, temp_driverpath );
 
-       snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile);
-       init_unistr( &info->datafile, temp_datafile );
+    if (strlen(driver.info_3->driverpath)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath);
+               init_unistr( &info->driverpath, temp );
+    } else
+        init_unistr( &info->driverpath, "" );
 
-       snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile);
-       init_unistr( &info->configfile, temp_configfile );      
+       if (strlen(driver.info_3->datafile)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile);
+               init_unistr( &info->datafile, temp );
+       } else
+               init_unistr( &info->datafile, "" );
+       
+       if (strlen(driver.info_3->configfile)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile);
+               init_unistr( &info->configfile, temp ); 
+       } else
+               init_unistr( &info->configfile, "" );
 }
 
 /********************************************************************
@@ -2830,10 +2838,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser
  ********************************************************************/
 static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
 {
-       pstring temp_driverpath;
-       pstring temp_datafile;
-       pstring temp_configfile;
-       pstring temp_helpfile;
+       pstring temp;
 
        ZERO_STRUCTP(info);
 
@@ -2842,17 +2847,29 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN
        init_unistr( &info->name, driver.info_3->name );        
        init_unistr( &info->architecture, driver.info_3->environment );
 
-       snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath);                
-       init_unistr( &info->driverpath, temp_driverpath );
-
-       snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile);
-       init_unistr( &info->datafile, temp_datafile );
-
-       snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile);
-       init_unistr( &info->configfile, temp_configfile );      
-
-       snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile);
-       init_unistr( &info->helpfile, temp_helpfile );
+    if (strlen(driver.info_3->driverpath)) {
+        snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath);             
+        init_unistr( &info->driverpath, temp );
+    } else
+        init_unistr( &info->driverpath, "" );
+    
+    if (strlen(driver.info_3->datafile)) {
+        snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile);
+        init_unistr( &info->datafile, temp );
+    } else
+        init_unistr( &info->datafile, "" );
+
+    if (strlen(driver.info_3->configfile)) {
+        snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile);
+        init_unistr( &info->configfile, temp );        
+    } else
+        init_unistr( &info->configfile, "" );
+
+    if (strlen(driver.info_3->helpfile)) {
+        snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile);
+        init_unistr( &info->helpfile, temp );
+    } else
+        init_unistr( &info->helpfile, "" );
 
        init_unistr( &info->monitorname, driver.info_3->monitorname );
        init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype );
@@ -2898,10 +2915,7 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst
 
 static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername)
 {
-       pstring temp_driverpath;
-       pstring temp_datafile;
-       pstring temp_configfile;
-       pstring temp_helpfile;
+       pstring temp;
        fstring nullstr;
 
        ZERO_STRUCTP(info);
@@ -2912,18 +2926,30 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN
        init_unistr( &info->name, driver.info_3->name );        
        init_unistr( &info->architecture, driver.info_3->environment );
 
-       snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath);                
-       init_unistr( &info->driverpath, temp_driverpath );
-
-       snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile);
-       init_unistr( &info->datafile, temp_datafile );
-
-       snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile);
-       init_unistr( &info->configfile, temp_configfile );      
-
-       snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile);
-       init_unistr( &info->helpfile, temp_helpfile );
-
+       if (strlen(driver.info_3->driverpath)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath);              
+               init_unistr( &info->driverpath, temp );
+       } else
+               init_unistr( &info->driverpath, "" );
+
+       if (strlen(driver.info_3->datafile)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile);
+               init_unistr( &info->datafile, temp );
+       } else
+               init_unistr( &info->datafile, "" );
+
+       if (strlen(driver.info_3->configfile)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile);
+               init_unistr( &info->configfile, temp ); 
+       } else
+               init_unistr( &info->configfile, "" );
+
+       if (strlen(driver.info_3->helpfile)) {
+               snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile);
+               init_unistr( &info->helpfile, temp );
+       } else
+               init_unistr( &info->helpfile, "" );
+       
        init_unistr( &info->monitorname, driver.info_3->monitorname );
        init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype );
 
index 69cca942953e24771e388df1381e3b7e9836288e..77bded6420f18f4cb3bfc98d06ed58453e8710b6 100755 (executable)
@@ -11,7 +11,7 @@ shift
 shift
 shift
 
-for d in $BASEDIR $BINDIR $LIBDIR $VARDIR; do
+for d in $BASEDIR $BINDIR $LIBDIR $VARDIR $BASEDIR/private; do
 if [ ! -d $d ]; then
 mkdir $d
 if [ ! -d $d ]; then
index d0abaab7aec32310cc85f7849236099e2307f17a..5b54df033e5be36b756f0692e89bf73162132eda 100755 (executable)
@@ -1,5 +1,11 @@
-#!/bin/sh -v
+#!/bin/sh
 SRCDIR=$1
+shift
+FILES=$@
+
+if test -z $FILES; then
+    FILES=*.yo
+fi
 
 YODLDIR=$SRCDIR/../docs/yodldocs
 MANPAGEDIR=$SRCDIR/../docs/manpages
@@ -24,7 +30,7 @@ fi
 
 cd $YODLDIR
 
-for d in *.yo
+for d in $FILES
 do
 
 #
index b0b4bbab7b7b67038e6263eae5e7f65f3f147444..8ab4e0c5d3f24cbd2e865ecc0fd4bdb88bf812d9 100644 (file)
@@ -57,6 +57,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
        key.pid = sys_getpid();
        key.cnum = conn?conn->cnum:-1;
        fstrcpy(key.name, name);
+       dos_to_unix(key.name, True);           /* Convert key to unix-codepage */
 
        kbuf.dptr = (char *)&key;
        kbuf.dsize = sizeof(key);
@@ -93,6 +94,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
        key.pid = sys_getpid();
        key.cnum = conn?conn->cnum:-1;
        fstrcpy(key.name, name);
+       dos_to_unix(key.name, True);           /* Convert key to unix-codepage */
 
        kbuf.dptr = (char *)&key;
        kbuf.dsize = sizeof(key);
index 25cadb51b0412da9951888a2d9ea7a117b9641ca..1d2b8f4e9f286eba2751cd9400c72bcb0099186b 100644 (file)
@@ -488,7 +488,7 @@ BOOL sid_to_gid(DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype)
         */
 
        if ((name_type != SID_NAME_DOM_GRP) && (name_type != SID_NAME_ALIAS) && (name_type != SID_NAME_WKN_GRP)) {
-               DEBUG(10,("sid_to_gid: winbind lookup succeeded but SID is not a know group (%u)\n",
+               DEBUG(10,("sid_to_gid: winbind lookup succeeded but SID is not a known group (%u)\n",
                                (unsigned int)name_type ));
 
                return local_sid_to_gid(pgid, psid, sidtype);
index d9fa46fe4ce7fcc66247ecaec0e0b44325a86876..ab28fd82b84698c1f61a36b290fd02da03698ae3 100644 (file)
@@ -326,6 +326,12 @@ static int process_root(int argc, char *argv[])
                usage();
        }
        
+       /* Only load interfaces if we are doing network operations. */
+
+       if (joining_domain || remote_machine) {
+               load_interfaces();
+       }
+
        if(joining_domain) {
                if (argc != 0)
                        usage();
@@ -501,11 +507,13 @@ static int process_nonroot(int argc, char *argv[])
         * via a remote machine (even if that machine is
         * localhost).
         */     
+
+       load_interfaces(); /* Delayed from main() */
+
        if (remote_machine == NULL) {
                remote_machine = "127.0.0.1";
        }
 
-
        if (remote_machine != NULL) {
                old_passwd = get_pass("Old SMB password:",stdin_passwd_get);
        }
@@ -580,7 +588,6 @@ int main(int argc, char **argv)
 
        codepage_initialise(lp_client_code_page());
 
-       load_interfaces();
        secrets_init();
 
        /* Check the effective uid - make sure we are not setuid */