1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

More updates on editreg.c to bring it better in line with the Samba source.

This commit is contained in:
Richard Sharpe 0001-01-01 00:00:00 +00:00
parent 3c66111f32
commit dc69a638b9

View File

@ -412,16 +412,16 @@ typedef struct val_list_s {
#define MAXSUBAUTHS 15 #define MAXSUBAUTHS 15
#endif #endif
typedef struct dom_sid_s { typedef struct sid_s {
unsigned char ver, auths; unsigned char ver, auths;
unsigned char auth[6]; unsigned char auth[6];
unsigned int sub_auths[MAXSUBAUTHS]; unsigned int sub_auths[MAXSUBAUTHS];
} DOM_SID; } sid_t;
typedef struct ace_struct_s { typedef struct ace_struct_s {
unsigned char type, flags; unsigned char type, flags;
unsigned int perms; /* Perhaps a better def is in order */ unsigned int perms; /* Perhaps a better def is in order */
DOM_SID *trustee; sid_t *trustee;
} ACE; } ACE;
typedef struct acl_struct_s { typedef struct acl_struct_s {
@ -432,7 +432,7 @@ typedef struct acl_struct_s {
typedef struct sec_desc_s { typedef struct sec_desc_s {
unsigned int rev, type; unsigned int rev, type;
DOM_SID *owner, *group; sid_t *owner, *group;
ACL *sacl, *dacl; ACL *sacl, *dacl;
} SEC_DESC; } SEC_DESC;
@ -537,7 +537,7 @@ typedef struct ace_struct {
unsigned char flags; unsigned char flags;
unsigned short length; unsigned short length;
unsigned int perms; unsigned int perms;
DOM_SID trustee; sid_t trustee;
} REG_ACE; } REG_ACE;
typedef struct acl_struct { typedef struct acl_struct {
@ -904,7 +904,7 @@ int nt_delete_key_by_name(REGF *regf, char *name)
} }
static static
int nt_delete_sid(DOM_SID *sid) int nt_delete_sid(sid_t *sid)
{ {
if (sid) free(sid); if (sid) free(sid);
@ -1173,15 +1173,15 @@ VAL_KEY *nt_delete_reg_value(REG_KEY *key, char *name)
* Convert a string of the form S-1-5-x[-y-z-r] to a SID * Convert a string of the form S-1-5-x[-y-z-r] to a SID
*/ */
static static
int string_to_sid(DOM_SID **sid, const char *sid_str) int sid_string_to_sid(sid_t **sid, const char *sid_str)
{ {
int i = 0, auth; int i = 0, auth;
const char *lstr; const char *lstr;
*sid = (DOM_SID *)malloc(sizeof(DOM_SID)); *sid = (sid_t *)malloc(sizeof(sid_t));
if (!*sid) return 0; if (!*sid) return 0;
bzero(*sid, sizeof(DOM_SID)); bzero(*sid, sizeof(sid_t));
if (strncmp(sid_str, "S-1-5", 5)) { if (strncmp(sid_str, "S-1-5", 5)) {
fprintf(stderr, "Does not conform to S-1-5...: %s\n", sid_str); fprintf(stderr, "Does not conform to S-1-5...: %s\n", sid_str);
@ -1226,7 +1226,7 @@ ACE *nt_create_ace(int type, int flags, unsigned int perms, const char *sid)
ace->type = type; ace->type = type;
ace->flags = flags; ace->flags = flags;
ace->perms = perms; ace->perms = perms;
if (!string_to_sid(&ace->trustee, sid)) if (!sid_string_to_sid(&ace->trustee, sid))
goto error; goto error;
return ace; return ace;
@ -1287,8 +1287,8 @@ SEC_DESC *nt_create_def_sec_desc(REGF *regf)
tmp->rev = 1; tmp->rev = 1;
tmp->type = 0x8004; tmp->type = 0x8004;
if (!string_to_sid(&tmp->owner, "S-1-5-32-544")) goto error; if (!sid_string_to_sid(&tmp->owner, "S-1-5-32-544")) goto error;
if (!string_to_sid(&tmp->group, "S-1-5-18")) goto error; if (!sid_string_to_sid(&tmp->group, "S-1-5-18")) goto error;
tmp->sacl = NULL; tmp->sacl = NULL;
tmp->dacl = nt_create_default_acl(regf); tmp->dacl = nt_create_default_acl(regf);
@ -1829,9 +1829,9 @@ KEY_SEC_DESC *lookup_create_sec_key(REGF *regf, SK_MAP *sk_map, int sk_off)
* We could allocate the SID to be only the size needed, but I am too lazy. * We could allocate the SID to be only the size needed, but I am too lazy.
*/ */
static static
DOM_SID *dup_sid(DOM_SID *sid) sid_t *dup_sid(sid_t *sid)
{ {
DOM_SID *tmp = (DOM_SID *)malloc(sizeof(DOM_SID)); sid_t *tmp = (sid_t *)malloc(sizeof(sid_t));
int i; int i;
if (!tmp) return NULL; if (!tmp) return NULL;
@ -1916,12 +1916,12 @@ SEC_DESC *process_sec_desc(REGF *regf, REG_SEC_DESC *sec_desc)
IVAL(&sec_desc->group_off)); IVAL(&sec_desc->group_off));
if (verbose) fprintf(stdout, "SEC_DESC DACL Off: %0X\n", if (verbose) fprintf(stdout, "SEC_DESC DACL Off: %0X\n",
IVAL(&sec_desc->dacl_off)); IVAL(&sec_desc->dacl_off));
tmp->owner = dup_sid((DOM_SID *)((char *)sec_desc + IVAL(&sec_desc->owner_off))); tmp->owner = dup_sid((sid_t *)((char *)sec_desc + IVAL(&sec_desc->owner_off)));
if (!tmp->owner) { if (!tmp->owner) {
free(tmp); free(tmp);
return NULL; return NULL;
} }
tmp->group = dup_sid((DOM_SID *)((char *)sec_desc + IVAL(&sec_desc->group_off))); tmp->group = dup_sid((sid_t *)((char *)sec_desc + IVAL(&sec_desc->group_off)));
if (!tmp->group) { if (!tmp->group) {
free(tmp); free(tmp);
return NULL; return NULL;
@ -2618,7 +2618,7 @@ void *nt_alloc_regf_space(REGF *regf, int size, unsigned int *off)
* Compute the size of a SID stored ... * Compute the size of a SID stored ...
*/ */
static static
unsigned int sid_size(DOM_SID *sid) unsigned int sid_size(sid_t *sid)
{ {
unsigned int size; unsigned int size;
@ -2686,7 +2686,7 @@ unsigned int sec_desc_size(SEC_DESC *sd)
* Store a SID at the location provided * Store a SID at the location provided
*/ */
static static
int nt_store_SID(REGF *regf, DOM_SID *sid, unsigned char *locn) int nt_store_SID(REGF *regf, sid_t *sid, unsigned char *locn)
{ {
int i; int i;
unsigned char *p = locn; unsigned char *p = locn;
@ -3864,7 +3864,7 @@ void print_perms(int perms)
} }
static static
void print_sid(DOM_SID *sid) void print_sid(sid_t *sid)
{ {
int i, comps = sid->auths; int i, comps = sid->auths;
fprintf(stdout, "S-%u-%u", sid->ver, sid->auth[5]); fprintf(stdout, "S-%u-%u", sid->ver, sid->auth[5]);
@ -3955,7 +3955,7 @@ int main(int argc, char *argv[])
char *cmd_file_name = NULL; char *cmd_file_name = NULL;
char *out_file_name = NULL; char *out_file_name = NULL;
CMD_FILE *cmd_file = NULL; CMD_FILE *cmd_file = NULL;
DOM_SID *lsid; sid_t *lsid;
if (argc < 2) { if (argc < 2) {
usage(); usage();
@ -3987,7 +3987,7 @@ int main(int argc, char *argv[])
case 'O': case 'O':
def_owner_sid_str = strdup(optarg); def_owner_sid_str = strdup(optarg);
regf_opt += 2; regf_opt += 2;
if (!string_to_sid(&lsid, def_owner_sid_str)) { if (!sid_string_to_sid(&lsid, def_owner_sid_str)) {
fprintf(stderr, "Default Owner SID: %s is incorrectly formatted\n", fprintf(stderr, "Default Owner SID: %s is incorrectly formatted\n",
def_owner_sid_str); def_owner_sid_str);
free(&def_owner_sid_str[0]); free(&def_owner_sid_str[0]);