trying to get HEAD building again. If you want the code
[sfrench/samba-autobuild/.git] / source3 / utils / pdbedit.c
index 4cb3db52b7f4a0be56089992a4e0e0ac9262f2f6..96d0d3c057fad35fe5fe0e0d7be71992c462ad7e 100644 (file)
 #define MASK_ALWAYS_GOOD       0x0000001F
 #define MASK_USER_GOOD         0x00401F00
 
+/*****************************************************************************
+ stubb functions
+****************************************************************************/
+
+void become_root( void )
+{
+        return;
+}
+
+void unbecome_root( void )
+{
+        return;
+}
+
+
 /*********************************************************
  Add all currently available users to another db
  ********************************************************/
@@ -91,7 +106,7 @@ static int export_groups (struct pdb_context *in, struct pdb_context *out) {
 
        if (NT_STATUS_IS_ERR(in->pdb_enum_group_mapping(in, SID_NAME_UNKNOWN,
                                                        &maps, &entries,
-                                                       False, False))) {
+                                                       False))) {
                fprintf(stderr, "Can't get group mappings!\n");
                return 1;
        }
@@ -112,7 +127,6 @@ static int export_groups (struct pdb_context *in, struct pdb_context *out) {
 static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdstyle)
 {
        uid_t uid;
-       gid_t gid;
        time_t tmp;
 
        /* TODO: chaeck if entry is a user or a workstation */
@@ -158,8 +172,7 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst
                char lm_passwd[33];
                char nt_passwd[33];
 
-               uid = -1;
-               sid_to_uid(pdb_get_user_sid(sam_pwent), &uid);
+               uid = nametouid(pdb_get_username(sam_pwent));
                pdb_sethexpwd(lm_passwd, pdb_get_lanman_passwd(sam_pwent), pdb_get_acct_ctrl(sam_pwent));
                pdb_sethexpwd(nt_passwd, pdb_get_nt_passwd(sam_pwent), pdb_get_acct_ctrl(sam_pwent));
                        
@@ -171,8 +184,7 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst
                       pdb_encode_acct_ctrl(pdb_get_acct_ctrl(sam_pwent),NEW_PW_FORMAT_SPACE_PADDED_LEN),
                       (uint32)pdb_get_pass_last_set_time(sam_pwent));
        } else {
-               uid = -1;
-               sid_to_uid(pdb_get_user_sid(sam_pwent), &uid);
+               uid = nametouid(pdb_get_username(sam_pwent));
                printf ("%s:%d:%s\n", pdb_get_username(sam_pwent), uid, pdb_get_fullname(sam_pwent));
        }
 
@@ -338,7 +350,7 @@ static int new_user (struct pdb_context *in, const char *username,
        NTSTATUS nt_status;
        char *password1, *password2, *staticpass;
        
-       if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pwent, username))) {
+       if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pwent, username, 0))) {
                DEBUG(0, ("could not create account to add new user %s\n", username));
                return -1;
        }
@@ -486,7 +498,7 @@ static int delete_user_entry (struct pdb_context *in, const char *username)
                return -1;
        }
 
-       if (NT_STATUS_IS_ERR(in->pdb_getsampwnam(in, samaccount, username))) {
+       if (!NT_STATUS_IS_OK(in->pdb_getsampwnam(in, samaccount, username))) {
                fprintf (stderr, "user %s does not exist in the passdb\n", username);
                return -1;
        }
@@ -512,7 +524,7 @@ static int delete_machine_entry (struct pdb_context *in, const char *machinename
                return -1;
        }
 
-       if (NT_STATUS_IS_ERR(in->pdb_getsampwnam(in, samaccount, name))) {
+       if (!NT_STATUS_IS_OK(in->pdb_getsampwnam(in, samaccount, name))) {
                fprintf (stderr, "machine %s does not exist in the passdb\n", name);
                return -1;
        }
@@ -591,7 +603,7 @@ int main (int argc, char **argv)
        
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
-               case 'V':
+               case 'C':
                        account_policy_value_set = True;
                        break;
                }
@@ -607,6 +619,9 @@ int main (int argc, char **argv)
                exit(1);
        }
 
+       if(!initialize_password_db(False))
+               exit(1);
+
        if (!init_names())
                exit(1);