1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

adding some samr parsing calls (group / alias adding / deleting)

added code that moves MACHINE.SID to DOMAIN_NAME.SID if it exists.
This commit is contained in:
Luke Leighton 0001-01-01 00:00:00 +00:00
parent 474f94f419
commit 51c1c31768
7 changed files with 1002 additions and 564 deletions

View File

@ -1411,7 +1411,7 @@ BOOL initialise_sam_password_db(void);
void *startsam21pwent(BOOL update);
void endsam21pwent(void *vp);
struct sam_passwd *getsam21pwent(void *vp);
struct sam_passwd *iterate_getsam21pwntnam(const char *name);
struct sam_passwd *iterate_getsam21pwntnam(const char *ntname);
struct sam_passwd *iterate_getsam21pwrid(uint32 rid);
struct sam_passwd *iterate_getsam21pwuid(uid_t uid);
struct sam_disp_info *getsamdisprid(uint32 rid);
@ -2028,12 +2028,6 @@ void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
uint16 total_num_entries, uint16 unk_0,
uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status);
void samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth);
void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
void samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
uint32 num_sam_entries, LOCAL_GRP *alss,
uint32 status);
void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
uint16 switch_level, uint32 start_idx, uint32 size);
void samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth);
@ -2046,6 +2040,8 @@ void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status);
void samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth);
void make_samr_q_open_group(SAMR_Q_OPEN_GROUP *q_c,
POLICY_HND *hnd, uint32 unk, uint32 rid);
void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
uint16 switch_level, uint32 start_idx, uint32 size);
void samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth);
@ -2054,14 +2050,32 @@ void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
DOMAIN_GRP *grp,
uint32 status);
void samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth);
void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
POLICY_HND *hnd);
void samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
uint32 num_gids, DOM_GID *gid, uint32 status);
void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
void samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
uint32 num_sam_entries, LOCAL_GRP *alss,
uint32 status);
void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
void make_samr_alias_info3(ALIAS_INFO3 *al3, char *acct_desc);
void samr_io_alias_info3(char *desc, ALIAS_INFO3 *al3, prs_struct *ps, int depth);
void samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR *ctr, prs_struct *ps, int depth);
void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
POLICY_HND *pol,
uint16 switch_level);
void samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth);
void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u,
uint16 switch_value, char *acct_desc,
void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u, ALIAS_INFO_CTR *ctr,
uint32 status);
void samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth);
void make_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO *q_u, POLICY_HND *hnd,
ALIAS_INFO_CTR *ctr);
void samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO *q_u, prs_struct *ps, int depth);
void samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO *r_u, prs_struct *ps, int depth);
void make_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u,
POLICY_HND *hnd,
DOM_SID *sid);
@ -2069,26 +2083,44 @@ void samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES *q_u, prs
void make_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES *r_u,
uint32 num_rids, uint32 *rid, uint32 status);
void samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES *r_u, prs_struct *ps, int depth);
void samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth);
void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
uint32 num_rids, uint32 *rid, uint8 *type, uint32 status);
void samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth);
void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
uint32 unknown_0, uint32 rid);
void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth);
void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
POLICY_HND *pol, uint32 rid,
uint32 num_gids, uint32 *gid);
void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth);
void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
uint32 num_aliases, fstring *als_name, uint8 *num_als_usrs,
uint32 status);
void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth);
void make_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, POLICY_HND *hnd);
void samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS *r_u, prs_struct *ps, int depth);
void make_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, POLICY_HND *hnd,
char *acct_desc);
void samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS *r_u, prs_struct *ps, int depth);
void make_samr_q_unk_aliasmem(SAMR_Q_UNK_ALIASMEM *q_u, POLICY_HND *hnd,
DOM_SID *sid);
void samr_io_q_unk_aliasmem(char *desc, SAMR_Q_UNK_ALIASMEM *q_u, prs_struct *ps, int depth);
void samr_io_r_unk_aliasmem(char *desc, SAMR_R_UNK_ALIASMEM *r_u, prs_struct *ps, int depth);
void make_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, POLICY_HND *hnd,
DOM_SID *sid);
void samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM *q_u, prs_struct *ps, int depth);
void samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM *r_u, prs_struct *ps, int depth);
void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
void samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth);
void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
uint32 num_rids, uint32 *rid, uint8 *type, uint32 status);
void samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth);
void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
POLICY_HND *pol,
uint32 unk_0, uint32 rid);
void samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth);
void samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth);
void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
POLICY_HND *hnd);
void samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
uint32 num_gids, DOM_GID *gid, uint32 status);
void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
POLICY_HND *hnd, uint16 switch_value);
void samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth);
@ -2143,17 +2175,6 @@ void samr_io_r_connect(char *desc, SAMR_R_CONNECT *r_u, prs_struct *ps, int dep
void make_samr_q_connect_anon(SAMR_Q_CONNECT_ANON *q_u);
void samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON *q_u, prs_struct *ps, int depth);
void samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON *r_u, prs_struct *ps, int depth);
void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
uint32 unknown_0, uint32 rid);
void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth);
void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
POLICY_HND *pol, uint32 rid,
uint32 num_gids, uint32 *gid);
void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name);
void samr_io_q_unknown_38(char *desc, SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth);
void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u);

View File

@ -108,7 +108,6 @@ SamrTestPrivateFunctionsUser
#define SAMR_ADD_ALIASMEM 0x20
#define SAMR_QUERY_ALIASMEM 0x21
#define SAMR_UNKNOWN_21 0x21
#define SAMR_OPEN_USER 0x22
#define SAMR_QUERY_USERINFO 0x24
@ -794,7 +793,7 @@ typedef struct r_samr_set_group_info
/* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
typedef struct q_samr_delete_dom_alias_info
{
POLICY_HND pol; /* policy handle */
POLICY_HND alias_pol; /* policy handle */
} SAMR_Q_DELETE_DOM_ALIAS;
@ -811,7 +810,7 @@ typedef struct r_samr_delete_dom_alias_info
/* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
typedef struct q_samr_create_dom_alias_info
{
POLICY_HND pol; /* policy handle */
POLICY_HND dom_pol; /* policy handle */
UNIHDR hdr_acct_desc;
UNISTR2 uni_acct_desc;
@ -824,7 +823,7 @@ typedef struct q_samr_create_dom_alias_info
/* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
typedef struct r_samr_create_dom_alias_info
{
POLICY_HND pol; /* policy handle */
POLICY_HND alias_pol; /* policy handle */
uint32 rid;
uint32 status;
@ -847,12 +846,10 @@ typedef struct samr_alias_info3
} ALIAS_INFO3;
/* SAMR_R_QUERY_ALIASINFO - SAM alias info */
typedef struct r_samr_query_aliasinfo_info
/* ALIAS_INFO_CTR */
typedef struct alias_info_ctr
{
uint32 ptr;
uint16 switch_value; /* 0x0003 */
/* uint8[2] padding */
uint16 switch_value;
union
{
@ -860,6 +857,14 @@ typedef struct r_samr_query_aliasinfo_info
} alias;
} ALIAS_INFO_CTR;
/* SAMR_R_QUERY_ALIASINFO - SAM alias info */
typedef struct r_samr_query_aliasinfo_info
{
uint32 ptr;
ALIAS_INFO_CTR *ctr;
uint32 status;
} SAMR_R_QUERY_ALIASINFO;
@ -868,16 +873,8 @@ typedef struct r_samr_query_aliasinfo_info
/* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
typedef struct q_samr_set_alias_info
{
POLICY_HND pol; /* policy handle */
uint16 switch_value1; /* 0x0003 */
uint16 switch_value2; /* 0x0003 */
union
{
ALIAS_INFO3 info3;
} alias;
POLICY_HND alias_pol; /* policy handle */
ALIAS_INFO_CTR *ctr;
} SAMR_Q_SET_ALIASINFO;
@ -1081,16 +1078,6 @@ typedef struct r_samr_open_user_info
} SAMR_R_OPEN_USER;
/* SAMR_Q_UNKNOWN_13 - probably an open alias in domain */
typedef struct q_samr_unknown_13_info
{
POLICY_HND alias_pol; /* policy handle */
uint16 unknown_1; /* 16 bit unknown - 0x0200 */
uint16 unknown_2; /* 16 bit unknown - 0x0000 */
} SAMR_Q_UNKNOWN_13;
/* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
typedef struct q_samr_unknown_32_info
@ -1142,7 +1129,8 @@ typedef struct r_samr_add_group_mem_info
/* SAMR_Q_OPEN_GROUP - probably an open */
typedef struct q_samr_open_group_info
{
uint32 unknown_0; /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
POLICY_HND domain_pol; /* policy handle */
uint32 unknown; /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
uint32 rid_group; /* rid */
} SAMR_Q_OPEN_GROUP;
@ -1171,7 +1159,7 @@ typedef struct q_samr_unknown_21_info
/* SAMR_Q_UNK_ALIASMEM - don't know! */
typedef struct q_samr_unk_alias_mem_info
{
POLICY_HND pol; /* policy handle */
POLICY_HND alias_pol; /* policy handle */
DOM_SID sid; /* member sid to be "something"ed to do with the alias */
@ -1189,7 +1177,7 @@ typedef struct r_samr_unk_alias_mem_info
/* SAMR_Q_ADD_ALIASMEM - probably an add member */
typedef struct q_samr_add_alias_mem_info
{
POLICY_HND pol; /* policy handle */
POLICY_HND alias_pol; /* policy handle */
DOM_SID sid; /* member sid to be added to alias */

View File

@ -235,19 +235,11 @@ static int copy_reg(char *source, const char *dest)
int dos_rename(char *from, char *to)
{
int rcode;
pstring zfrom, zto;
pstrcpy (zfrom, dos_to_unix (from, False));
pstrcpy (zto, dos_to_unix (to, False));
rcode = rename (zfrom, zto);
if (errno == EXDEV)
{
/* Rename across filesystems needed. */
rcode = copy_reg (zfrom, zto);
}
return rcode;
return file_rename(zfrom, zto);
}
/*******************************************************************

View File

@ -277,6 +277,7 @@ BOOL generate_sam_sid(char *domain_name)
int i;
char *p;
pstring sid_file;
pstring machine_sid_file;
fstring sid_string;
fstring file_name;
SMB_STRUCT_STAT st;
@ -304,10 +305,29 @@ BOOL generate_sam_sid(char *domain_name)
}
}
pstrcpy(machine_sid_file, sid_file);
pstrcat(machine_sid_file, "MACHINE.SID");
slprintf(file_name, sizeof(file_name)-1, "%s.SID", domain_name);
strupper(file_name);
pstrcat(sid_file, file_name);
if (file_exists(machine_sid_file, NULL))
{
if (file_exists(machine_sid_file, NULL))
{
DEBUG(0,("both %s and %s exist when only one should, unable to continue\n",
machine_sid_file, sid_file));
return False;
}
if (file_rename(machine_sid_file, sid_file))
{
DEBUG(0,("could not rename %s to %s. Error was %s\n",
machine_sid_file, sid_file, strerror(errno)));
return False;
}
}
if ((fd = sys_open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) {
DEBUG(0,("unable to open or create file %s. Error was %s\n",
sid_file, strerror(errno) ));

View File

@ -366,6 +366,21 @@ BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf)
return(S_ISREG(sbuf->st_mode));
}
/*******************************************************************
rename a unix file
********************************************************************/
int file_rename(char *from, char *to)
{
int rcode = rename (from, to);
if (errno == EXDEV)
{
/* Rename across filesystems needed. */
rcode = copy_reg (from, to);
}
return rcode;
}
/*******************************************************************
check a files mod time
********************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -678,8 +678,9 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u,
prs_struct *rdata)
{
SAMR_R_QUERY_ALIASINFO r_e;
ALIAS_INFO_CTR ctr;
uint32 status = 0x0;
r_e.status = 0x0;
r_e.ptr = 0;
/* find the policy handle. open a policy on it. */
@ -690,17 +691,21 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u,
DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__));
if (r_e.status == 0x0)
if (status == 0x0)
{
if (q_u->switch_level != 3)
if (q_u->switch_level == 3)
{
r_e.status = NT_STATUS_INVALID_INFO_CLASS;
status = NT_STATUS_INVALID_INFO_CLASS;
}
else
{
r_e.ptr = 1;
ctr.switch_value = 3;
make_samr_alias_info3(&ctr.alias.info3, "<account description>");
}
}
make_samr_r_query_aliasinfo(&r_e, q_u->switch_level,
"<account description>",
r_e.status);
make_samr_r_query_aliasinfo(&r_e, status == 0 ? &ctr : NULL, status);
/* store the response in the SMB stream */
samr_io_r_query_aliasinfo("", &r_e, rdata, 0);