Remove pstring from auth/*
authorJeremy Allison <jra@samba.org>
Wed, 14 Nov 2007 18:37:18 +0000 (10:37 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 14 Nov 2007 18:37:18 +0000 (10:37 -0800)
Jeremy.

source/auth/auth_util.c
source/auth/pass_check.c

index 99eea6cdd259d2975901df0ce7890b1dadc6e09a..7ef894239efa2f0ccfb6ff113c4781f0d7a01890 100644 (file)
 
 static int smb_create_user(const char *domain, const char *unix_username, const char *homedir)
 {
-       pstring add_script;
+       TALLOC_CTX *ctx = talloc_tos();
+       char *add_script;
        int ret;
 
-       pstrcpy(add_script, lp_adduser_script());
-       if (! *add_script)
+       add_script = talloc_strdup(ctx, lp_adduser_script());
+       if (!add_script || !*add_script) {
                return -1;
-       all_string_sub(add_script, "%u", unix_username, sizeof(pstring));
-       if (domain)
-               all_string_sub(add_script, "%D", domain, sizeof(pstring));
-       if (homedir)
-               all_string_sub(add_script, "%H", homedir, sizeof(pstring));
+       }
+       add_script = talloc_all_string_sub(ctx,
+                               add_script,
+                               "%u",
+                               unix_username);
+       if (!add_script) {
+               return -1;
+       }
+       if (domain) {
+               add_script = talloc_all_string_sub(ctx,
+                                       add_script,
+                                       "%D",
+                                       domain);
+               if (!add_script) {
+                       return -1;
+               }
+       }
+       if (homedir) {
+               add_script = talloc_all_string_sub(ctx,
+                               add_script,
+                               "%H",
+                               homedir);
+               if (!add_script) {
+                       return -1;
+               }
+       }
        ret = smbrun(add_script,NULL);
        flush_pwnam_cache();
-       DEBUG(ret ? 0 : 3,("smb_create_user: Running the command `%s' gave %d\n",add_script,ret));
+       DEBUG(ret ? 0 : 3,
+               ("smb_create_user: Running the command `%s' gave %d\n",
+                add_script,ret));
        return ret;
 }
 
@@ -53,15 +77,15 @@ static int smb_create_user(const char *domain, const char *unix_username, const
  Create an auth_usersupplied_data structure
 ****************************************************************************/
 
-static NTSTATUS make_user_info(auth_usersupplied_info **user_info, 
-                               const char *smb_name, 
+static NTSTATUS make_user_info(auth_usersupplied_info **user_info,
+                               const char *smb_name,
                                const char *internal_username,
-                               const char *client_domain, 
+                               const char *client_domain,
                                const char *domain,
-                               const char *wksta_name, 
+                               const char *wksta_name,
                                DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
                                DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
-                               DATA_BLOB *plaintext, 
+                               DATA_BLOB *plaintext,
                                bool encrypted)
 {
 
index 8773804a385bc39166858ad835e7bcb9321ed219..27915bf4999281e4561c419d58e399af622034c5 100644 (file)
@@ -599,7 +599,7 @@ return NT_STATUS_OK on correct match, appropriate error otherwise
 NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *password, 
                    int pwlen, bool (*fn) (const char *, const char *), bool run_cracker)
 {
-       pstring pass2;
+       char *pass2 = NULL;
        int level = lp_passwordlevel();
 
        NTSTATUS nt_status;
@@ -758,7 +758,10 @@ NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *pas
        }
 
        /* make a copy of it */
-       pstrcpy(pass2, password);
+       pass2 = talloc_strdup(talloc_tos(), password);
+       if (!pass2) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* try all lowercase if it's currently all uppercase */
        if (strhasupper(pass2)) {