samdb: Rework samdb_connect_url() to return LDB error code and an error string
[samba.git] / source3 / passdb / pdb_smbpasswd.c
index 99b275de4068118d20b9de82e18d4afa2de28137..9c381471ddae384328541af58f401568f0a2f9e6 100644 (file)
@@ -39,7 +39,7 @@
 
 struct smb_passwd
 {
-        uint32 smb_userid;        /* this is actually the unix uid_t */
+        uint32_t smb_userid;      /* this is actually the unix uid_t */
         const char *smb_name;     /* username string */
 
         const unsigned char *smb_passwd;    /* Null if no password */
@@ -737,7 +737,8 @@ static bool mod_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state, con
        fstring user_name;
 
        char *status;
-       char linebuf[256];
+#define LINEBUF_SIZE 255
+       char linebuf[LINEBUF_SIZE + 1];
        char readbuf[1024];
        int c;
        fstring ascii_p16;
@@ -792,7 +793,7 @@ static bool mod_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state, con
 
                linebuf[0] = '\0';
 
-               status = fgets(linebuf, sizeof(linebuf), fp);
+               status = fgets(linebuf, LINEBUF_SIZE, fp);
                if (status == NULL && ferror(fp)) {
                        pw_file_unlock(lockfd, &smbpasswd_state->pw_file_lock_depth);
                        fclose(fp);
@@ -1018,10 +1019,10 @@ This is no longer supported.!\n", pwd->smb_name));
 
 #ifdef DEBUG_PASSWORD
        DEBUG(100,("mod_smbfilepwd_entry: "));
-       dump_data(100, (uint8 *)ascii_p16, wr_len);
+       dump_data(100, (uint8_t *)ascii_p16, wr_len);
 #endif
 
-       if(wr_len > sizeof(linebuf)) {
+       if(wr_len > LINEBUF_SIZE) {
                DEBUG(0, ("mod_smbfilepwd_entry: line to write (%d) is too long.\n", wr_len+1));
                pw_file_unlock(lockfd,&smbpasswd_state->pw_file_lock_depth);
                fclose(fp);
@@ -1205,9 +1206,9 @@ static bool build_smb_pass (struct smb_passwd *smb_pw, const struct samu *sampas
 
                /* If the user specified a RID, make sure its able to be both stored and retreived */
                if (rid == DOMAIN_RID_GUEST) {
-                       struct passwd *passwd = Get_Pwnam_alloc(NULL, lp_guestaccount());
+                       struct passwd *passwd = Get_Pwnam_alloc(NULL, lp_guest_account());
                        if (!passwd) {
-                               DEBUG(0, ("Could not find guest account via Get_Pwnam_alloc()! (%s)\n", lp_guestaccount()));
+                               DEBUG(0, ("Could not find guest account via Get_Pwnam_alloc()! (%s)\n", lp_guest_account()));
                                return False;
                        }
                        smb_pw->smb_userid=passwd->pw_uid;
@@ -1342,7 +1343,7 @@ static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, struct sam
 
        /* More special case 'guest account' hacks... */
        if (rid == DOMAIN_RID_GUEST) {
-               const char *guest_account = lp_guestaccount();
+               const char *guest_account = lp_guest_account();
                if (!(guest_account && *guest_account)) {
                        DEBUG(1, ("Guest account not specfied!\n"));
                        return nt_status;
@@ -1448,7 +1449,7 @@ static NTSTATUS smbpasswd_rename_sam_account (struct pdb_methods *my_methods,
        TALLOC_CTX *ctx = talloc_tos();
        NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
 
-       if (!*(lp_renameuser_script()))
+       if (!*(lp_rename_user_script(talloc_tos())))
                goto done;
 
        if ( !(new_acct = samu_new( NULL )) ) {
@@ -1468,8 +1469,7 @@ static NTSTATUS smbpasswd_rename_sam_account (struct pdb_methods *my_methods,
        interim_account = True;
 
        /* rename the posix user */
-       rename_script = talloc_strdup(ctx,
-                               lp_renameuser_script());
+       rename_script = lp_rename_user_script(ctx);
        if (!rename_script) {
                ret = NT_STATUS_NO_MEMORY;
                goto done;
@@ -1501,7 +1501,7 @@ static NTSTATUS smbpasswd_rename_sam_account (struct pdb_methods *my_methods,
                        goto done;
                }
 
-               rename_ret = smbrun(rename_script, NULL);
+               rename_ret = smbrun(rename_script, NULL, NULL);
 
                DEBUG(rename_ret ? 0 : 3,("Running the command `%s' gave %d\n", rename_script, rename_ret));
 
@@ -1720,7 +1720,7 @@ static NTSTATUS pdb_init_smbpasswd( struct pdb_methods **pdb_method, const char
        return NT_STATUS_OK;
 }
 
-NTSTATUS pdb_smbpasswd_init(void
+NTSTATUS pdb_smbpasswd_init(TALLOC_CTX *ctx
 {
        return smb_register_passdb(PASSDB_INTERFACE_VERSION, "smbpasswd", pdb_init_smbpasswd);
 }