From c424c2b857fe08587eb81a5c5e3625545119d1c2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Apr 2004 16:24:08 +0000 Subject: r20: Add the registry library. Still needs a lot of work, see source/lib/registry/TODO for details. (This used to be commit 7cab3a00d7b4b1d95a3bfa6b28f318b4aaa5d493) --- source4/lib/registry/tools/regpatch.c | 808 ++++++++++++++++++++++++++++++++++ 1 file changed, 808 insertions(+) create mode 100644 source4/lib/registry/tools/regpatch.c (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c new file mode 100644 index 0000000000..f76da7ebf9 --- /dev/null +++ b/source4/lib/registry/tools/regpatch.c @@ -0,0 +1,808 @@ +/* + Unix SMB/CIFS implementation. + simple registry frontend + + Copyright (C) 2002, Richard Sharpe, rsharpe@richardsharpe.com + Copyright (C) 2004, Jelmer Vernooij, jelmer@samba.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * Routines to parse a REGEDIT4 file + * + * The file consists of: + * + * REGEDIT4 + * \[[-]key-path\]\n + * * + * + * Format: + * [cmd:]name=type:value + * + * cmd = a|d|c|add|delete|change|as|ds|cs + * + * There can be more than one key-path and value-spec. + * + * Since we want to support more than one type of file format, we + * construct a command-file structure that keeps info about the command file + */ + +#define FMT_UNREC -1 +#define FMT_REGEDIT4 0 +#define FMT_EDITREG1_1 1 + +#define FMT_STRING_REGEDIT4 "REGEDIT4" +#define FMT_STRING_EDITREG1_0 "EDITREG1.0" + +#define CMD_NONE 0 +#define CMD_ADD_KEY 1 +#define CMD_DEL_KEY 2 + +#define CMD_KEY 1 +#define CMD_VAL 2 + +#include + +typedef struct val_spec_list { + struct val_spec_list *next; + char *name; + int type; + char *val; /* Kept as a char string, really? */ +} VAL_SPEC_LIST; + +typedef struct command_s { + int cmd; + char *key; + int val_count; + VAL_SPEC_LIST *val_spec_list, *val_spec_last; +} CMD; + +typedef struct cmd_line { + int len, line_len; + char *line; +} CMD_LINE; + +static void free_val_spec_list(VAL_SPEC_LIST *vl) +{ + if (!vl) return; + if (vl->name) free(vl->name); + if (vl->val) free(vl->val); + free(vl); + +} + +/* + * Some routines to handle lines of info in the command files + */ +static void skip_to_eol(int fd) +{ + int rc; + char ch = 0; + + while ((rc = read(fd, &ch, 1)) == 1) { + if (ch == 0x0A) return; + } + if (rc < 0) { + DEBUG(0, ("Could not read file descriptor: %d, %s\n", + fd, strerror(errno))); + exit(1); + } +} + +static void free_cmd(CMD *cmd) +{ + if (!cmd) return; + + while (cmd->val_spec_list) { + VAL_SPEC_LIST *tmp; + + tmp = cmd->val_spec_list; + cmd->val_spec_list = tmp->next; + free(tmp); + } + + free(cmd); + +} + +static void free_cmd_line(CMD_LINE *cmd_line) +{ + if (cmd_line) { + if (cmd_line->line) free(cmd_line->line); + free(cmd_line); + } +} + +static void print_line(struct cmd_line *cl) +{ + char *pl; + + if (!cl) return; + + pl = smb_xmalloc(cl->line_len + 1); + + strncpy(pl, cl->line, cl->line_len); + pl[cl->line_len] = 0; + + fprintf(stdout, "%s\n", pl); + free(pl); +} + +#define INIT_ALLOC 10 + +/* + * Read a line from the input file. + * NULL returned when EOF and no chars read + * Otherwise we return a cmd_line * + * Exit if other errors + */ +static struct cmd_line *get_cmd_line(int fd) +{ + struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE)); + int i = 0, rc; + unsigned char ch; + + cl->len = INIT_ALLOC; + + /* + * Allocate some space for the line. We extend later if needed. + */ + + cl->line = (char *)smb_xmalloc(INIT_ALLOC); + + /* + * Now read in the chars to EOL. Don't store the EOL in the + * line. What about CR? + */ + + while ((rc = read(fd, &ch, 1)) == 1 && ch != '\n') { + if (ch == '\r') continue; /* skip CR */ + if (i == cl->len) { + /* + * Allocate some more memory + */ + if ((cl->line = realloc(cl->line, cl->len + INIT_ALLOC)) == NULL) { + DEBUG(0, ("Unable to realloc space for line: %s\n", + strerror(errno))); + exit(1); + } + cl->len += INIT_ALLOC; + } + cl->line[i] = ch; + i++; + } + + /* read 0 and we were at loc'n 0, return NULL */ + if (rc == 0 && i == 0) { + free_cmd_line(cl); + return NULL; + } + + cl->line_len = i; + + return cl; + +} + +/* + * parse_value: parse out a value. We pull it apart as: + * + * ::= =: + * + * ::= char-string-without-spaces | '"' char-string '"' + * + * If it parsed OK, return the as a string, and the + * value type and value-string in parameters. + * + * The value name can be empty. There can only be one empty name in + * a list of values. A value of - removes the value entirely. + */ + +static char *parse_name(char *nstr) +{ + int len = 0, start = 0; + if (!nstr) return NULL; + + len = strlen(nstr); + + while (len && nstr[len - 1] == ' ') len--; + + nstr[len] = 0; /* Trim any spaces ... if there were none, doesn't matter */ + + /* + * Beginning and end should be '"' or neither should be so + */ + if ((nstr[0] == '"' && nstr[len - 1] != '"') || + (nstr[0] != '"' && nstr[len - 1] == '"')) + return NULL; + + if (nstr[0] == '"') { + start = 1; + len -= 2; + } + + return strndup(&nstr[start], len); +} + +static int parse_value_type(char *tstr) +{ + int len = strlen(tstr); + + while (len && tstr[len - 1] == ' ') len--; + tstr[len] = 0; + + if (strcmp(tstr, "REG_DWORD") == 0) + return REG_DWORD; + else if (strcmp(tstr, "dword") == 0) + return REG_DWORD; + else if (strcmp(tstr, "REG_EXPAND_SZ") == 0) + return REG_EXPAND_SZ; + else if (strcmp(tstr, "REG_BIN") == 0) + return REG_BINARY; + else if (strcmp(tstr, "REG_SZ") == 0) + return REG_SZ; + else if (strcmp(tstr, "REG_MULTI_SZ") == 0) + return REG_MULTI_SZ; + else if (strcmp(tstr, "-") == 0) + return REG_DELETE; + + return 0; +} + +static char *parse_val_str(char *vstr) +{ + + return strndup(vstr, strlen(vstr)); + +} + +static char *parse_value(struct cmd_line *cl, int *vtype, char **val) +{ + char *p1 = NULL, *p2 = NULL, *nstr = NULL, *tstr = NULL, *vstr = NULL; + + if (!cl || !vtype || !val) return NULL; + if (!cl->line_len) return NULL; + + p1 = strndup(cl->line, cl->line_len); + /* FIXME: Better return codes etc ... */ + if (!p1) return NULL; + p2 = strchr(p1, '='); + if (!p2) return NULL; + + *p2 = 0; p2++; /* Split into two strings at p2 */ + + /* Now, parse the name ... */ + + nstr = parse_name(p1); + if (!nstr) goto error; + + /* Now, split the remainder and parse on type and val ... */ + + tstr = p2; + while (*tstr == ' ') tstr++; /* Skip leading white space */ + p2 = strchr(p2, ':'); + + if (p2) { + *p2 = 0; p2++; /* split on the : */ + } + + *vtype = parse_value_type(tstr); + + if (!vtype) goto error; + + if (!p2 || !*p2) return nstr; + + /* Now, parse the value string. It should return a newly malloc'd string */ + + while (*p2 == ' ') p2++; /* Skip leading space */ + vstr = parse_val_str(p2); + + if (!vstr) goto error; + + *val = vstr; + + return nstr; + + error: + if (p1) free(p1); + if (nstr) free(nstr); + if (vstr) free(vstr); + return NULL; +} + +/* + * Parse out a key. Look for a correctly formatted key [...] + * and whether it is a delete or add? A delete is signalled + * by a - in front of the key. + * Assumes that there are no leading and trailing spaces + */ + +static char *parse_key(struct cmd_line *cl, int *cmd) +{ + int start = 1; + char *tmp; + + if (cl->line[0] != '[' || + cl->line[cl->line_len - 1] != ']') return NULL; + if (cl->line_len == 2) return NULL; + *cmd = CMD_ADD_KEY; + if (cl->line[1] == '-') { + if (cl->line_len == 3) return NULL; + start = 2; + *cmd = CMD_DEL_KEY; + } + tmp = smb_xmalloc(cl->line_len - 1 - start + 1); + strncpy(tmp, &cl->line[start], cl->line_len - 1 - start); + tmp[cl->line_len - 1 - start] = 0; + return tmp; +} + +/* + * Parse a line to determine if we have a key or a value + * We only check for key or val ... + */ + +static int parse_line(struct cmd_line *cl) +{ + + if (!cl || cl->len == 0) return 0; + + if (cl->line[0] == '[') /* No further checking for now */ + return CMD_KEY; + else + return CMD_VAL; +} + +/* + * We seek to offset 0, read in the required number of bytes, + * and compare to the correct value. + * We then seek back to the original location + */ +static int regedit4_file_type(int fd) +{ + int cur_ofs = 0; + char desc[9]; + + cur_ofs = lseek(fd, 0, SEEK_CUR); /* Get current offset */ + if (cur_ofs < 0) { + DEBUG(0, ("Unable to get current offset: %s\n", strerror(errno))); + exit(1); /* FIXME */ + } + + if (cur_ofs) { + lseek(fd, 0, SEEK_SET); + } + + if (read(fd, desc, 8) < 8) { + DEBUG(0, ("Unable to read command file format\n")); + exit(2); /* FIXME */ + } + + desc[8] = 0; + + if (strcmp(desc, FMT_STRING_REGEDIT4) == 0) { + if (cur_ofs) { + lseek(fd, cur_ofs, SEEK_SET); + } + else { + skip_to_eol(fd); + } + return FMT_REGEDIT4; + } + + return FMT_UNREC; +} + +/* + * Run though the data in the line and strip anything after a comment + * char. + */ +static void strip_comment(struct cmd_line *cl) +{ + int i; + + if (!cl) return; + + for (i = 0; i < cl->line_len; i++) { + if (cl->line[i] == ';') { + cl->line_len = i; + return; + } + } +} + +/* + * trim leading space + */ + +static void trim_leading_spaces(struct cmd_line *cl) +{ + int i; + + if (!cl) return; + + for (i = 0; i < cl->line_len; i++) { + if (cl->line[i] != ' '){ + if (i) memcpy(cl->line, &cl->line[i], cl->line_len - i); + return; + } + } +} + +/* + * trim trailing spaces + */ +static void trim_trailing_spaces(struct cmd_line *cl) +{ + int i; + + if (!cl) return; + + for (i = cl->line_len; i == 0; i--) { + if (cl->line[i-1] != ' ' && + cl->line[i-1] != '\t') { + cl->line_len = i; + } + } +} + +/* + * Get a command ... This consists of possibly multiple lines: + * [key] + * values* + * possibly Empty line + * + * value ::= =':' + * is some path, possibly enclosed in quotes ... + * We alctually look for the next key to terminate a previous key + * if == '-', then it is a delete type. + */ +static CMD *regedit4_get_cmd(int fd) +{ + struct command_s *cmd = NULL; + struct cmd_line *cl = NULL; + struct val_spec_list *vl = NULL; + + cmd = (struct command_s *)smb_xmalloc(sizeof(struct command_s)); + + cmd->cmd = CMD_NONE; + cmd->key = NULL; + cmd->val_count = 0; + cmd->val_spec_list = cmd->val_spec_last = NULL; + while ((cl = get_cmd_line(fd))) { + + /* + * If it is an empty command line, and we already have a key + * then exit from here ... FIXME: Clean up the parser + */ + + if (cl->line_len == 0 && cmd->key) { + free_cmd_line(cl); + break; + } + + strip_comment(cl); /* remove anything beyond a comment char */ + trim_trailing_spaces(cl); + trim_leading_spaces(cl); + + if (cl->line_len == 0) { /* An empty line */ + free_cmd_line(cl); + } + else { /* Else, non-empty ... */ + /* + * Parse out the bits ... + */ + switch (parse_line(cl)) { + case CMD_KEY: + if ((cmd->key = parse_key(cl, &cmd->cmd)) == NULL) { + DEBUG(0, ("Error parsing key from line: ")); + print_line(cl); + DEBUG(0, ("\n")); + } + break; + + case CMD_VAL: + /* + * We need to add the value stuff to the list + * There could be a \ on the end which we need to + * handle at some time + */ + vl = (struct val_spec_list *)smb_xmalloc(sizeof(struct val_spec_list)); + vl->next = NULL; + vl->val = NULL; + vl->name = parse_value(cl, &vl->type, &vl->val); + if (!vl->name) goto error; + if (cmd->val_spec_list == NULL) { + cmd->val_spec_list = cmd->val_spec_last = vl; + } + else { + cmd->val_spec_last->next = vl; + cmd->val_spec_last = vl; + } + cmd->val_count++; + break; + + default: + DEBUG(0, ("Unrecognized line in command file: \n")); + print_line(cl); + break; + } + } + + } + if (!cmd->cmd) goto error; /* End of file ... */ + + return cmd; + + error: + if (vl) free(vl); + if (cmd) free_cmd(cmd); + return NULL; +} + +static int regedit4_exec_cmd(CMD *cmd) +{ + + return 0; +} + +static int editreg_1_0_file_type(int fd) +{ + int cur_ofs = 0; + char desc[11]; + + cur_ofs = lseek(fd, 0, SEEK_CUR); /* Get current offset */ + if (cur_ofs < 0) { + DEBUG(0, ("Unable to get current offset: %s\n", strerror(errno))); + exit(1); /* FIXME */ + } + + if (cur_ofs) { + lseek(fd, 0, SEEK_SET); + } + + if (read(fd, desc, 10) < 10) { + DEBUG(0, ("Unable to read command file format\n")); + exit(2); /* FIXME */ + } + + desc[10] = 0; + + if (strcmp(desc, FMT_STRING_EDITREG1_0) == 0) { + lseek(fd, cur_ofs, SEEK_SET); + return FMT_REGEDIT4; + } + + return FMT_UNREC; +} + +static CMD *editreg_1_0_get_cmd(int fd) +{ + return NULL; +} + +static int editreg_1_0_exec_cmd(CMD *cmd) +{ + + return -1; +} + +typedef struct command_ops_s { + int type; + int (*file_type)(int fd); + CMD *(*get_cmd)(int fd); + int (*exec_cmd)(CMD *cmd); +} CMD_OPS; + +CMD_OPS default_cmd_ops[] = { + {0, regedit4_file_type, regedit4_get_cmd, regedit4_exec_cmd}, + {1, editreg_1_0_file_type, editreg_1_0_get_cmd, editreg_1_0_exec_cmd}, + {-1, NULL, NULL, NULL} +}; + +typedef struct command_file_s { + char *name; + int type, fd; + CMD_OPS cmd_ops; +} CMD_FILE; + +/* + * Create a new command file structure + */ + +static CMD_FILE *cmd_file_create(char *file) +{ + CMD_FILE *tmp; + struct stat sbuf; + int i = 0; + + /* + * Let's check if the file exists ... + * No use creating the cmd_file structure if the file does not exist + */ + + if (stat(file, &sbuf) < 0) { /* Not able to access file */ + + return NULL; + } + + tmp = (CMD_FILE *)smb_xmalloc(sizeof(CMD_FILE)); + + /* + * Let's fill in some of the fields; + */ + + tmp->name = strdup(file); + + if ((tmp->fd = open(file, O_RDONLY, 666)) < 0) { + free(tmp); + return NULL; + } + + /* + * Now, try to find the format by indexing through the table + */ + while (default_cmd_ops[i].type != -1) { + if ((tmp->type = default_cmd_ops[i].file_type(tmp->fd)) >= 0) { + tmp->cmd_ops = default_cmd_ops[i]; + return tmp; + } + i++; + } + + /* + * If we got here, return NULL, as we could not figure out the type + * of command file. + * + * What about errors? + */ + + free(tmp); + return NULL; +} + +/* + * Extract commands from the command file, and execute them. + * We pass a table of command callbacks for that + */ + +//FIXME + +/* + * Main code from here on ... + */ + +/* + * key print function here ... + */ + +/* + * Sec Desc print functions + */ + +char *str_type(unsigned char type); + +int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) +{ + CMD *cmd; + int modified = 0; + CMD_FILE *cmd_file = NULL; + cmd_file = cmd_file_create(cmd_file_name); + + while ((cmd = cmd_file->cmd_ops.get_cmd(cmd_file->fd)) != NULL) { + + /* + * Now, apply the requests to the tree ... + */ + switch (cmd->cmd) { + case CMD_ADD_KEY: { + REG_KEY *tmp = NULL; + tmp = reg_open_key(reg_get_root(regf), cmd->key); + /* If we found it, apply the other bits, else create such a key */ + if (!tmp) { + if(reg_key_add_name(reg_get_root(regf), cmd->key)) { + tmp = reg_open_key(reg_get_root(regf), cmd->key); + } + modified = 1; + } + + while (cmd->val_count) { + VAL_SPEC_LIST *val = cmd->val_spec_list; + REG_VAL *reg_val = NULL; + + if (val->type == REG_DELETE) { + reg_val = reg_key_get_value_by_name( tmp, val->name); + reg_val_del(reg_val); + modified = 1; + } + else { + /* FIXME + reg_val = nt_add_reg_value(tmp, val->name, val->type, + val->val); */ + modified = 1; + } + + cmd->val_spec_list = val->next; + free_val_spec_list(val); + cmd->val_count--; + } + + break; + } + + case CMD_DEL_KEY: + /* + * Any value does not matter ... + * Find the key if it exists, and delete it ... + */ + + reg_key_del_recursive(reg_open_key(reg_get_root(regf), cmd->key)); + modified = 1; + break; + } + } + free_cmd(cmd); + + return modified; +} + +int main (int argc, char **argv) +{ + uint32 setparms, checkparms; + int opt; + poptContext pc; + REG_KEY *root; + const char *location; + const char *patch; + char *backend = "dir"; + REG_HANDLE *h; + int fullpath = 0, no_values = 0; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"backend", 'b', POPT_ARG_STRING, &backend, 'b', "backend to use", NULL}, + POPT_TABLEEND + }; + + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); + + while((opt = poptGetNextOpt(pc)) != -1) { + } + + setup_logging(argv[0], True); + + location = poptGetArg(pc); + if(!location) { + poptPrintUsage(pc, stderr, 0); + return 1; + } + + h = reg_open(backend, location, True); + if(!h) { + fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location, backend); + return 1; + } + + poptFreeContext(pc); + + patch = poptGetArg(pc); + if(!patch) patch = "/dev/stdin"; + + nt_apply_reg_command_file(h, patch); + + return 0; +} -- cgit From 69c19afb6226e93a244490fa582200364a3b7069 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Apr 2004 09:17:11 +0000 Subject: r31: More registry updates. regdiff/regpatch work now. (This used to be commit 98224f5436695eb265f5d997cf4bc9cf735a4fb9) --- source4/lib/registry/tools/regpatch.c | 148 +++++++++++++--------------------- 1 file changed, 58 insertions(+), 90 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index f76da7ebf9..27f578e37f 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -172,7 +172,7 @@ static struct cmd_line *get_cmd_line(int fd) while ((rc = read(fd, &ch, 1)) == 1 && ch != '\n') { if (ch == '\r') continue; /* skip CR */ - if (i == cl->len) { + if (i == cl->len-1) { /* * Allocate some more memory */ @@ -193,6 +193,7 @@ static struct cmd_line *get_cmd_line(int fd) return NULL; } + cl->line[i] = '\0'; cl->line_len = i; return cl; @@ -276,9 +277,9 @@ static char *parse_value(struct cmd_line *cl, int *vtype, char **val) char *p1 = NULL, *p2 = NULL, *nstr = NULL, *tstr = NULL, *vstr = NULL; if (!cl || !vtype || !val) return NULL; - if (!cl->line_len) return NULL; + if (!cl->line[0]) return NULL; - p1 = strndup(cl->line, cl->line_len); + p1 = strdup(cl->line); /* FIXME: Better return codes etc ... */ if (!p1) return NULL; p2 = strchr(p1, '='); @@ -380,7 +381,7 @@ static int regedit4_file_type(int fd) cur_ofs = lseek(fd, 0, SEEK_CUR); /* Get current offset */ if (cur_ofs < 0) { - DEBUG(0, ("Unable to get current offset: %s\n", strerror(errno))); + DEBUG(0, ("Unable to get current offset: (%d) %s\n", cur_ofs, strerror(errno))); exit(1); /* FIXME */ } @@ -398,8 +399,7 @@ static int regedit4_file_type(int fd) if (strcmp(desc, FMT_STRING_REGEDIT4) == 0) { if (cur_ofs) { lseek(fd, cur_ofs, SEEK_SET); - } - else { + } else { skip_to_eol(fd); } return FMT_REGEDIT4; @@ -420,47 +420,13 @@ static void strip_comment(struct cmd_line *cl) for (i = 0; i < cl->line_len; i++) { if (cl->line[i] == ';') { + cl->line[i] = '\0'; cl->line_len = i; return; } } } -/* - * trim leading space - */ - -static void trim_leading_spaces(struct cmd_line *cl) -{ - int i; - - if (!cl) return; - - for (i = 0; i < cl->line_len; i++) { - if (cl->line[i] != ' '){ - if (i) memcpy(cl->line, &cl->line[i], cl->line_len - i); - return; - } - } -} - -/* - * trim trailing spaces - */ -static void trim_trailing_spaces(struct cmd_line *cl) -{ - int i; - - if (!cl) return; - - for (i = cl->line_len; i == 0; i--) { - if (cl->line[i-1] != ' ' && - cl->line[i-1] != '\t') { - cl->line_len = i; - } - } -} - /* * Get a command ... This consists of possibly multiple lines: * [key] @@ -497,10 +463,9 @@ static CMD *regedit4_get_cmd(int fd) } strip_comment(cl); /* remove anything beyond a comment char */ - trim_trailing_spaces(cl); - trim_leading_spaces(cl); + trim_string(cl->line, " \t", " \t"); - if (cl->line_len == 0) { /* An empty line */ + if (!cl->line[0]) { /* An empty line */ free_cmd_line(cl); } else { /* Else, non-empty ... */ @@ -625,7 +590,7 @@ typedef struct command_file_s { * Create a new command file structure */ -static CMD_FILE *cmd_file_create(char *file) +static CMD_FILE *cmd_file_create(const char *file) { CMD_FILE *tmp; struct stat sbuf; @@ -637,7 +602,7 @@ static CMD_FILE *cmd_file_create(char *file) */ if (stat(file, &sbuf) < 0) { /* Not able to access file */ - + DEBUG(0,("Stat on %s failed\n", file)); return NULL; } @@ -650,6 +615,7 @@ static CMD_FILE *cmd_file_create(char *file) tmp->name = strdup(file); if ((tmp->fd = open(file, O_RDONLY, 666)) < 0) { + DEBUG(0,("Error opening %s\n", file)); free(tmp); return NULL; } @@ -673,6 +639,7 @@ static CMD_FILE *cmd_file_create(char *file) */ free(tmp); + DEBUG(0,("Unknown type\n")); return NULL; } @@ -711,49 +678,51 @@ int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) */ switch (cmd->cmd) { case CMD_ADD_KEY: { - REG_KEY *tmp = NULL; - tmp = reg_open_key(reg_get_root(regf), cmd->key); - /* If we found it, apply the other bits, else create such a key */ - if (!tmp) { - if(reg_key_add_name(reg_get_root(regf), cmd->key)) { - tmp = reg_open_key(reg_get_root(regf), cmd->key); - } - modified = 1; - } - - while (cmd->val_count) { - VAL_SPEC_LIST *val = cmd->val_spec_list; - REG_VAL *reg_val = NULL; - - if (val->type == REG_DELETE) { - reg_val = reg_key_get_value_by_name( tmp, val->name); - reg_val_del(reg_val); - modified = 1; - } - else { - /* FIXME - reg_val = nt_add_reg_value(tmp, val->name, val->type, - val->val); */ - modified = 1; - } - - cmd->val_spec_list = val->next; - free_val_spec_list(val); - cmd->val_count--; - } - - break; + REG_KEY *tmp = NULL; + tmp = reg_open_key(reg_get_root(regf), cmd->key); + /* If we found it, apply the other bits, else create such a key */ + if (!tmp) { + if(reg_key_add_name_recursive(reg_get_root(regf), cmd->key)) { + tmp = reg_open_key(reg_get_root(regf), cmd->key); + } else { + DEBUG(0, ("Error adding new key '%s'\n", cmd->key)); + } + modified = 1; + } + + while (cmd->val_count) { + VAL_SPEC_LIST *val = cmd->val_spec_list; + REG_VAL *reg_val = NULL; + + if (val->type == REG_DELETE) { + reg_val = reg_key_get_value_by_name( tmp, val->name); + reg_val_del(reg_val); + modified = 1; + } + else { + /* FIXME + reg_val = nt_add_reg_value(tmp, val->name, val->type, + val->val); */ + modified = 1; + } + + cmd->val_spec_list = val->next; + free_val_spec_list(val); + cmd->val_count--; + } + + break; } case CMD_DEL_KEY: - /* - * Any value does not matter ... - * Find the key if it exists, and delete it ... - */ - - reg_key_del_recursive(reg_open_key(reg_get_root(regf), cmd->key)); - modified = 1; - break; + /* + * Any value does not matter ... + * Find the key if it exists, and delete it ... + */ + + reg_key_del_recursive(reg_open_key(reg_get_root(regf), cmd->key)); + modified = 1; + break; } } free_cmd(cmd); @@ -779,7 +748,7 @@ int main (int argc, char **argv) }; pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); - + while((opt = poptGetNextOpt(pc)) != -1) { } @@ -797,12 +766,11 @@ int main (int argc, char **argv) return 1; } - poptFreeContext(pc); - patch = poptGetArg(pc); if(!patch) patch = "/dev/stdin"; + poptFreeContext(pc); nt_apply_reg_command_file(h, patch); - + return 0; } -- cgit From 9cbbf2d55253783adaeceac9bc2f8c9ffe40aa94 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 9 Apr 2004 00:02:20 +0000 Subject: r129: Convert other utilities to new API (This used to be commit 95c9852b1607335eb24025081a251139449fb695) --- source4/lib/registry/tools/regpatch.c | 77 +++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 22 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 27f578e37f..9a51b0f7ff 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -664,11 +664,13 @@ static CMD_FILE *cmd_file_create(const char *file) char *str_type(unsigned char type); -int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) +int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) { CMD *cmd; - int modified = 0; + BOOL modified = False; CMD_FILE *cmd_file = NULL; + REG_KEY *tmp = NULL; + WERROR error; cmd_file = cmd_file_create(cmd_file_name); while ((cmd = cmd_file->cmd_ops.get_cmd(cmd_file->fd)) != NULL) { @@ -677,17 +679,22 @@ int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) * Now, apply the requests to the tree ... */ switch (cmd->cmd) { - case CMD_ADD_KEY: { - REG_KEY *tmp = NULL; - tmp = reg_open_key(reg_get_root(regf), cmd->key); + case CMD_ADD_KEY: + error = reg_open_key(root, cmd->key, &tmp); + /* If we found it, apply the other bits, else create such a key */ - if (!tmp) { - if(reg_key_add_name_recursive(reg_get_root(regf), cmd->key)) { - tmp = reg_open_key(reg_get_root(regf), cmd->key); + if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { + if(W_ERROR_IS_OK(reg_key_add_name_recursive(root, cmd->key))) { + error = reg_open_key(root, cmd->key, &tmp); + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error finding new key '%s' after it has been added\n", cmd->key)); + continue; + } } else { DEBUG(0, ("Error adding new key '%s'\n", cmd->key)); + continue; } - modified = 1; + modified = True; } while (cmd->val_count) { @@ -695,15 +702,21 @@ int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) REG_VAL *reg_val = NULL; if (val->type == REG_DELETE) { - reg_val = reg_key_get_value_by_name( tmp, val->name); - reg_val_del(reg_val); - modified = 1; + error = reg_key_get_value_by_name( tmp, val->name, ®_val); + if(W_ERROR_IS_OK(error)) { + error = reg_val_del(reg_val); + } + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error removing value '%s'\n", val->name)); + } + modified = True; } else { - /* FIXME - reg_val = nt_add_reg_value(tmp, val->name, val->type, - val->val); */ - modified = 1; + if(!W_ERROR_IS_OK(reg_key_add_value(tmp, val->name, val->type, val->val, strlen(val->val)))) { + DEBUG(0, ("Error adding new value '%s'\n", val->name)); + continue; + } + modified = True; } cmd->val_spec_list = val->next; @@ -712,7 +725,6 @@ int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) } break; - } case CMD_DEL_KEY: /* @@ -720,8 +732,18 @@ int nt_apply_reg_command_file(REG_HANDLE *regf, const char *cmd_file_name) * Find the key if it exists, and delete it ... */ - reg_key_del_recursive(reg_open_key(reg_get_root(regf), cmd->key)); - modified = 1; + error = reg_open_key(root, cmd->key, &tmp); + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Unable to open key '%s'\n", cmd->key)); + continue; + } + + error = reg_key_del_recursive(tmp); + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Unable to delete key '%s'\n", cmd->key)); + continue; + } + modified = True; break; } } @@ -737,13 +759,16 @@ int main (int argc, char **argv) poptContext pc; REG_KEY *root; const char *location; + const char *credentials = NULL; const char *patch; - char *backend = "dir"; + const char *backend = "dir"; REG_HANDLE *h; int fullpath = 0, no_values = 0; + WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP {"backend", 'b', POPT_ARG_STRING, &backend, 'b', "backend to use", NULL}, + {"credentials", 'c', POPT_ARG_STRING, &credentials, 'c', "credentials (user%password", NULL}, POPT_TABLEEND }; @@ -760,7 +785,7 @@ int main (int argc, char **argv) return 1; } - h = reg_open(backend, location, True); + error = reg_open(backend, location, credentials, &h); if(!h) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location, backend); return 1; @@ -770,7 +795,15 @@ int main (int argc, char **argv) if(!patch) patch = "/dev/stdin"; poptFreeContext(pc); - nt_apply_reg_command_file(h, patch); + error = reg_get_root(h, &root); + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error opening root!\n")); + return 1; + } + + nt_apply_reg_command_file(root, patch); + + reg_free(h); return 0; } -- cgit From f3d3b3c8091ad4540c330c07662540440affb96e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 25 Apr 2004 22:15:48 +0000 Subject: r355: Fix a bunch of compiler warnings in the registry code. (This used to be commit 0be7a866dc39e2d63c9c114d0f668287259e7c9e) --- source4/lib/registry/tools/regpatch.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 9a51b0f7ff..e632edaa49 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -754,7 +754,6 @@ int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) int main (int argc, char **argv) { - uint32 setparms, checkparms; int opt; poptContext pc; REG_KEY *root; @@ -763,7 +762,6 @@ int main (int argc, char **argv) const char *patch; const char *backend = "dir"; REG_HANDLE *h; - int fullpath = 0, no_values = 0; WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP -- cgit From 6a8355a6282563e3198c05dd6eb82107e449682c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 4 May 2004 13:18:29 +0000 Subject: r467: hopefully get the buildfarm compiling fine now... metze (This used to be commit d15f0e18bb43608c611cfe78fc79db9ee10e1eb2) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index e632edaa49..d4b036afe9 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -752,7 +752,7 @@ int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) return modified; } -int main (int argc, char **argv) + int main(int argc, char **argv) { int opt; poptContext pc; -- cgit From f236700ef67d4f93ec56ec7808584552e94e0dfe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 May 2004 10:20:53 +0000 Subject: r665: merge over the new build system from my tmp branch to the main SAMBA_4_0 tree. NOTE: that it's not completely ready, but it's functional:-) metze (This used to be commit c78a2ddb28ec50d6570a83b1f66f18a5c3621731) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index d4b036afe9..64c2637a0c 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -664,7 +664,7 @@ static CMD_FILE *cmd_file_create(const char *file) char *str_type(unsigned char type); -int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) +static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) { CMD *cmd; BOOL modified = False; -- cgit From bf52e242f53aeaac33eea69fbdfb3477634b90fb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 May 2004 18:49:25 +0000 Subject: r825: - Introduce support for multiple roots (or 'hives') - Clean up rpc backend (possible now that multiple hives are supported) (This used to be commit 8cd1b6bc70510fe576135a66351e9e3ea895c9ff) --- source4/lib/registry/tools/regpatch.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 64c2637a0c..77c0f710c1 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -664,7 +664,7 @@ static CMD_FILE *cmd_file_create(const char *file) char *str_type(unsigned char type); -static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) +static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) { CMD *cmd; BOOL modified = False; @@ -680,12 +680,12 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) */ switch (cmd->cmd) { case CMD_ADD_KEY: - error = reg_open_key(root, cmd->key, &tmp); + error = reg_open_key_abs(r, cmd->key, &tmp); /* If we found it, apply the other bits, else create such a key */ if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { - if(W_ERROR_IS_OK(reg_key_add_name_recursive(root, cmd->key))) { - error = reg_open_key(root, cmd->key, &tmp); + if(W_ERROR_IS_OK(reg_key_add_name_recursive_abs(r, cmd->key))) { + error = reg_open_key_abs(r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error finding new key '%s' after it has been added\n", cmd->key)); continue; @@ -732,7 +732,7 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) * Find the key if it exists, and delete it ... */ - error = reg_open_key(root, cmd->key, &tmp); + error = reg_open_key_abs(r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Unable to open key '%s'\n", cmd->key)); continue; @@ -756,7 +756,6 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) { int opt; poptContext pc; - REG_KEY *root; const char *location; const char *credentials = NULL; const char *patch; @@ -793,13 +792,7 @@ static int nt_apply_reg_command_file(REG_KEY *root, const char *cmd_file_name) if(!patch) patch = "/dev/stdin"; poptFreeContext(pc); - error = reg_get_root(h, &root); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error opening root!\n")); - return 1; - } - - nt_apply_reg_command_file(root, patch); + nt_apply_reg_command_file(h, patch); reg_free(h); -- cgit From 45e93c19ef95978f908f5b14962770510634cd3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 29 May 2004 08:11:46 +0000 Subject: r943: change samba4 to use 'uint8_t' instead of 'unsigned char' metze (This used to be commit b5378803fdcb3b3afe7c2932a38828e83470f61a) --- source4/lib/registry/tools/regpatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 77c0f710c1..af869d1cfa 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -155,7 +155,7 @@ static struct cmd_line *get_cmd_line(int fd) { struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE)); int i = 0, rc; - unsigned char ch; + uint8_t ch; cl->len = INIT_ALLOC; @@ -662,7 +662,7 @@ static CMD_FILE *cmd_file_create(const char *file) * Sec Desc print functions */ -char *str_type(unsigned char type); +char *str_type(uint8_t type); static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) { -- cgit From 664f50e81cc97eac7162cb3dd324eaefb11aa7d2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 18 Aug 2004 19:57:49 +0000 Subject: r1894: Convert // to /* */ (This used to be commit 5dc793b2b4b5c54df4aa3b0c98c248bdd671bbb1) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index af869d1cfa..7eddea2b93 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -648,7 +648,7 @@ static CMD_FILE *cmd_file_create(const char *file) * We pass a table of command callbacks for that */ -//FIXME +/* FIXME */ /* * Main code from here on ... -- cgit From 369a5d64e462e084e6c5fe4984d56da18b2c92d9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 22 Sep 2004 12:32:31 +0000 Subject: r2518: Some long overdue changes: - Samba4-style code in lib/registry (struct registry_key instead of REG_KEY, etc) - Use hives (like Windows has drives) instead of one root key (like a Unix FS) - usability fixes in the GTK utilities (autodetect the username, enable/disable options, etc) - fix gwsam compile - several bugfixes in the registry rpc code - do charset conversion in nt4 registry backend (This used to be commit 2762ed3b9bf1d67dd54d63e02cddbfd71ea89892) --- source4/lib/registry/tools/regpatch.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 7eddea2b93..1b33628a71 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -664,12 +664,13 @@ static CMD_FILE *cmd_file_create(const char *file) char *str_type(uint8_t type); -static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) +static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd_file_name) { CMD *cmd; BOOL modified = False; CMD_FILE *cmd_file = NULL; - REG_KEY *tmp = NULL; + TALLOC_CTX *mem_ctx = talloc_init("apply_cmd_file"); + struct registry_key *tmp = NULL; WERROR error; cmd_file = cmd_file_create(cmd_file_name); @@ -680,12 +681,12 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) */ switch (cmd->cmd) { case CMD_ADD_KEY: - error = reg_open_key_abs(r, cmd->key, &tmp); + error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); /* If we found it, apply the other bits, else create such a key */ if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { if(W_ERROR_IS_OK(reg_key_add_name_recursive_abs(r, cmd->key))) { - error = reg_open_key_abs(r, cmd->key, &tmp); + error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error finding new key '%s' after it has been added\n", cmd->key)); continue; @@ -699,12 +700,12 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) while (cmd->val_count) { VAL_SPEC_LIST *val = cmd->val_spec_list; - REG_VAL *reg_val = NULL; + struct registry_value *reg_val = NULL; if (val->type == REG_DELETE) { - error = reg_key_get_value_by_name( tmp, val->name, ®_val); + error = reg_key_get_value_by_name( mem_ctx, tmp, val->name, ®_val); if(W_ERROR_IS_OK(error)) { - error = reg_val_del(reg_val); + error = reg_del_value(reg_val); } if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error removing value '%s'\n", val->name)); @@ -712,7 +713,7 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) modified = True; } else { - if(!W_ERROR_IS_OK(reg_key_add_value(tmp, val->name, val->type, val->val, strlen(val->val)))) { + if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, val->val, strlen(val->val)))) { DEBUG(0, ("Error adding new value '%s'\n", val->name)); continue; } @@ -732,7 +733,7 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) * Find the key if it exists, and delete it ... */ - error = reg_open_key_abs(r, cmd->key, &tmp); + error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Unable to open key '%s'\n", cmd->key)); continue; @@ -760,7 +761,7 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) const char *credentials = NULL; const char *patch; const char *backend = "dir"; - REG_HANDLE *h; + struct registry_context *h; WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP @@ -769,6 +770,12 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) POPT_TABLEEND }; + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); + } + + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { @@ -782,7 +789,7 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) return 1; } - error = reg_open(backend, location, credentials, &h); + error = reg_open(&h, backend, location, credentials); if(!h) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location, backend); return 1; @@ -794,7 +801,7 @@ static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) nt_apply_reg_command_file(h, patch); - reg_free(h); + talloc_destroy(h->mem_ctx); return 0; } -- cgit From 9ba6c3885acb79d9c35e600f9a67f8ed0200edfd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 29 Oct 2004 12:12:24 +0000 Subject: r3368: Default to rpc backend with binding "ncalrpc:" if no backend was specified in the various registry tools. Allow opening a remote registry to partly fail (I.e. if not all hives could be opened) (This used to be commit 313034b10d7a70d079e2bec1af38cf2a7cd918c1) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 1b33628a71..eed249d353 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -760,7 +760,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd const char *location; const char *credentials = NULL; const char *patch; - const char *backend = "dir"; + const char *backend = "rpc"; struct registry_context *h; WERROR error; struct poptOption long_options[] = { -- cgit From edbfc0f6e70150e321822365bf0eead2821551bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:57:18 +0000 Subject: r3453: - split out the auth and popt includes - tidied up some of the system includes - moved a few more structures back from misc.idl to netlogon.idl and samr.idl now that pidl knows about inter-IDL dependencies (This used to be commit 7b7477ac42d96faac1b0ff361525d2c63cedfc64) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index eed249d353..298a922fbf 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" /* * Routines to parse a REGEDIT4 file -- cgit From a42142439aee9e75796e25cdf05e042174926abf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 06:52:59 +0000 Subject: r3464: split out registry.h, rap.h and ldap_server.h (This used to be commit 70d2090f6bf2c7e0caf1e9c020f330de88871f8e) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 298a922fbf..ae4d331e3c 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "registry.h" #include "lib/cmdline/popt_common.h" /* -- cgit From 6f214cc510a59b7a65ee9d4486baf14a3e579f73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 3 Nov 2004 00:17:12 +0000 Subject: r3494: got rid of include/rewrite.h, and split out the dynconfig.h header (This used to be commit 558de54ec6432a4ae90aa14a585f32c6cd03ced2) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index ae4d331e3c..38eabb60a9 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "registry.h" #include "lib/cmdline/popt_common.h" -- cgit From e8010adffe44f1ad0d82c7b5c7d5fe2cf7d53afd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 07:23:06 +0000 Subject: r3543: fixed some #include lines to make them more consistent, and fixed conditional compilation of xattr client code (This used to be commit 321fb06a627f4deae649ab014bc881721d37b3dd) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 38eabb60a9..4ad7e162a3 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -59,7 +59,7 @@ #define CMD_KEY 1 #define CMD_VAL 2 -#include +#include "includes.h" typedef struct val_spec_list { struct val_spec_list *next; -- cgit From 3a7eff64f27158dc428d3f881c4dc1e613ac6665 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 09:19:42 +0000 Subject: r3546: including includes.h twice causes gcc 3.4 to crash with pch (This used to be commit 51c1c2af687ed351d12e6d933659d94f5925728c) --- source4/lib/registry/tools/regpatch.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 4ad7e162a3..d70d7b8457 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -59,8 +59,6 @@ #define CMD_KEY 1 #define CMD_VAL 2 -#include "includes.h" - typedef struct val_spec_list { struct val_spec_list *next; char *name; -- cgit From 71db46ea665606384f2be1be708c74c97c9adfb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Nov 2004 23:23:15 +0000 Subject: r3586: Fix some of the issues with the module init functions. Both subsystems and modules can now have init functions, which can be specified in .mk files (INIT_FUNCTION = ...) The build system will define : - SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal - BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on This removes the hack with the "static bool Initialised = " and the "lazy_init" functions (This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index d70d7b8457..a8b2f83ee1 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -771,6 +771,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd POPT_TABLEEND }; + regpatch_init_subsystems; if (!lp_load(dyn_CONFIGFILE,True,False,False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); -- cgit From 2f9e170f45e128eb6ab6bd97c9c8b40dcd9a97fa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 4 Dec 2004 09:30:38 +0000 Subject: r4058: added a type safe version of smb_xmalloc() (This used to be commit 1235afa5fe3a396cd7a180cbc500834a30fbaa80) --- source4/lib/registry/tools/regpatch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index a8b2f83ee1..9b37b7952b 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -154,7 +154,7 @@ static void print_line(struct cmd_line *cl) */ static struct cmd_line *get_cmd_line(int fd) { - struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE)); + struct cmd_line *cl = smb_xmalloc_p(CMD_LINE); int i = 0, rc; uint8_t ch; @@ -445,7 +445,7 @@ static CMD *regedit4_get_cmd(int fd) struct cmd_line *cl = NULL; struct val_spec_list *vl = NULL; - cmd = (struct command_s *)smb_xmalloc(sizeof(struct command_s)); + cmd = smb_xmalloc_p(struct command_s); cmd->cmd = CMD_NONE; cmd->key = NULL; @@ -488,7 +488,7 @@ static CMD *regedit4_get_cmd(int fd) * There could be a \ on the end which we need to * handle at some time */ - vl = (struct val_spec_list *)smb_xmalloc(sizeof(struct val_spec_list)); + vl = smb_xmalloc_p(struct val_spec_list); vl->next = NULL; vl->val = NULL; vl->name = parse_value(cl, &vl->type, &vl->val); @@ -607,7 +607,7 @@ static CMD_FILE *cmd_file_create(const char *file) return NULL; } - tmp = (CMD_FILE *)smb_xmalloc(sizeof(CMD_FILE)); + tmp = smb_xmalloc_p(CMD_FILE); /* * Let's fill in some of the fields; -- cgit From 9922c2d0357a89db4ee4abbb0beded6a0f24b010 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 4 Dec 2004 14:28:06 +0000 Subject: r4064: use the same name for type on both ends for long term we should remove all typedef's metze (This used to be commit 4b3f552cb373a0d91526412fc31699959c96a007) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 9b37b7952b..be60b96019 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -154,7 +154,7 @@ static void print_line(struct cmd_line *cl) */ static struct cmd_line *get_cmd_line(int fd) { - struct cmd_line *cl = smb_xmalloc_p(CMD_LINE); + CMD_LINE *cl = smb_xmalloc_p(CMD_LINE); int i = 0, rc; uint8_t ch; -- cgit From 444a86792471c0bef33dde15c7a4a33e16a951b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 10 Dec 2004 20:07:04 +0000 Subject: r4132: - Bunch of rather large fixes in the registry - Added some README files Not everything works yet, e.g. the EnumValue test appears to be broken. (This used to be commit c169e86c1f52763b83e77e509f89cb91f9b69071) --- source4/lib/registry/tools/regpatch.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index be60b96019..a4a4649c96 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -758,16 +758,14 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd { int opt; poptContext pc; - const char *location; - const char *credentials = NULL; const char *patch; - const char *backend = "rpc"; struct registry_context *h; + const char *remote = NULL; WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP - {"backend", 'b', POPT_ARG_STRING, &backend, 'b', "backend to use", NULL}, - {"credentials", 'c', POPT_ARG_STRING, &credentials, 'c', "credentials (user%password", NULL}, + POPT_COMMON_CREDENTIALS + {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, POPT_TABLEEND }; @@ -785,25 +783,22 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd setup_logging(argv[0], True); - location = poptGetArg(pc); - if(!location) { - poptPrintUsage(pc, stderr, 0); - return 1; + if (remote) { + error = reg_open_remote (&h, cmdline_get_username(), cmdline_get_userpassword(), remote); + } else { + error = reg_open_local (&h); } - error = reg_open(&h, backend, location, credentials); - if(!h) { - fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location, backend); + if (W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error: %s\n", win_errstr(error)); return 1; } - + patch = poptGetArg(pc); if(!patch) patch = "/dev/stdin"; poptFreeContext(pc); nt_apply_reg_command_file(h, patch); - talloc_destroy(h->mem_ctx); - return 0; } -- cgit From 47fa1d33e4a6b9aeaf06ad2c12d9744bdf967bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Dec 2004 00:45:29 +0000 Subject: r4166: More small API fixes, keep registry structs as small as possible. Implement DelValue in the RPC server (This used to be commit f6b9ec89af934e837069fb26c0e3491fc78ebc12) --- source4/lib/registry/tools/regpatch.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index a4a4649c96..18589a9285 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -701,13 +701,9 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd while (cmd->val_count) { VAL_SPEC_LIST *val = cmd->val_spec_list; - struct registry_value *reg_val = NULL; if (val->type == REG_DELETE) { - error = reg_key_get_value_by_name( mem_ctx, tmp, val->name, ®_val); - if(W_ERROR_IS_OK(error)) { - error = reg_del_value(reg_val); - } + error = reg_del_value(tmp, val->name); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error removing value '%s'\n", val->name)); } -- cgit From 1a340869c43f9ce741e8a4bd28ea01ec63301df5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Dec 2004 20:49:18 +0000 Subject: r4204: Arguments to reg_del_key more like the RPC for more efficient usage Fix small bug in regpatch Fix segfault in regshell cmdline completion Implement set_value and del_value in ldb backend (This used to be commit 8e2aa58abeafa78afe7dafb9723f5f365e756527) --- source4/lib/registry/tools/regpatch.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 18589a9285..600c1f60e7 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -686,13 +686,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd /* If we found it, apply the other bits, else create such a key */ if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { - if(W_ERROR_IS_OK(reg_key_add_name_recursive_abs(r, cmd->key))) { - error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error finding new key '%s' after it has been added\n", cmd->key)); - continue; - } - } else { + if(!W_ERROR_IS_OK(reg_key_add_abs(mem_ctx, r, cmd->key, 0, NULL, &tmp))) { DEBUG(0, ("Error adding new key '%s'\n", cmd->key)); continue; } @@ -730,13 +724,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd * Find the key if it exists, and delete it ... */ - error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open key '%s'\n", cmd->key)); - continue; - } - - error = reg_key_del_recursive(tmp); + error = reg_key_del_abs(r, cmd->key); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Unable to delete key '%s'\n", cmd->key)); continue; -- cgit From 73a0b6ea476ee19bb814c3257daca7c116d42872 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 31 Jan 2005 15:58:54 +0000 Subject: r5134: - fix types to always use _t types - add #include "system/filesys.h" where needed metze (This used to be commit 6bb07a0ed8a4baaeaa1d63bde8ce773364860fd2) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 600c1f60e7..ee7568cc0f 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -24,6 +24,7 @@ #include "dynconfig.h" #include "registry.h" #include "lib/cmdline/popt_common.h" +#include "system/filesys.h" /* * Routines to parse a REGEDIT4 file -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index ee7568cc0f..ce3d9a7e1b 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -769,7 +769,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd setup_logging(argv[0], True); if (remote) { - error = reg_open_remote (&h, cmdline_get_username(), cmdline_get_userpassword(), remote); + error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote); } else { error = reg_open_local (&h); } -- cgit From 05bc2d7b2c11a3583a6d1221cfbd618eb6730518 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 21:22:07 +0000 Subject: r5928: Use cli_credentials in: - gtk+ (returned by GtkHostBindingDialog as well now) - torture/ - librpc/ - lib/com/dcom/ (This used to be commit ccefd782335e01e8e6ecb2bcd28a4f999c53b1a6) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index ce3d9a7e1b..2462fd8241 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -769,7 +769,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd setup_logging(argv[0], True); if (remote) { - error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote); + error = reg_open_remote (&h, cmdline_credentials, remote); } else { error = reg_open_local (&h); } -- cgit From 5b18cf22680c76abb1262a6b75a30b8a37899467 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 15 May 2005 20:16:26 +0000 Subject: r6795: Make some functions static and remove some unused ones. (This used to be commit 46509eb89980bfe6dabd71264d570ea356ee5a22) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 2462fd8241..aeb418560d 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -576,7 +576,7 @@ typedef struct command_ops_s { int (*exec_cmd)(CMD *cmd); } CMD_OPS; -CMD_OPS default_cmd_ops[] = { +static CMD_OPS default_cmd_ops[] = { {0, regedit4_file_type, regedit4_get_cmd, regedit4_exec_cmd}, {1, editreg_1_0_file_type, editreg_1_0_get_cmd, editreg_1_0_exec_cmd}, {-1, NULL, NULL, NULL} -- cgit From 4867378592656d812fcd02d1ea24ccb2c99bf9b7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 24 May 2005 05:51:20 +0000 Subject: r6951: Fix all calls to setup_logging() that use 'True' as a second argument. In Samba4 this is now an enum. Possibly by accident, True just happens to map to the right value in this case. (-: (This used to be commit affacc539864435cbc749a4c1a6b848c61b7182b) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index aeb418560d..5c9851b71b 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -766,7 +766,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd while((opt = poptGetNextOpt(pc)) != -1) { } - setup_logging(argv[0], True); + setup_logging(argv[0], DEBUG_STDOUT); if (remote) { error = reg_open_remote (&h, cmdline_credentials, remote); -- cgit From 2b4791ae733488845b2c36bca64db695203de571 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 08:12:39 +0000 Subject: r7525: Unify lp_load(), load_interfaces and logging setup into popt(). There is now a new --debug-stderr option to enable debug to STDERR. popt isn't perfect, but the callbacks are used in all the main Samba binaries, and should be used in the rest. This avoids duplicated code, and ensures every binary is setup correctly. This also ensures the setup happens early enough to have -s function, and have a correct impact on the credentials code. (Fixing a bug that frustrated tridge earlier today). The only 'subtle' aspect of all this is that I'm pretty sure that the SAMBA_COMMON popt code must be above the CREDENTIALS code, in the popt tables. Andrew Bartlett (This used to be commit 50f3c2b3a22971f40e0d3a88127b5120bfc47591) --- source4/lib/registry/tools/regpatch.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 5c9851b71b..02ef4d4655 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -749,25 +749,19 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_CREDENTIALS {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS POPT_TABLEEND }; regpatch_init_subsystems; - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); - } - - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { } - setup_logging(argv[0], DEBUG_STDOUT); - if (remote) { error = reg_open_remote (&h, cmdline_credentials, remote); } else { -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 02ef4d4655..3ada9f66e2 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -763,7 +763,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote); + error = reg_open_remote (&h, cmdline_credentials, remote, NULL); } else { error = reg_open_local (&h); } -- cgit From a92e61c4528b46628275216c9252a7a7f6e07dfc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Aug 2005 03:22:25 +0000 Subject: r9503: removed duplicate REG_* defines from registry.h now that they are generated in winreg.h (This used to be commit fc15e1b003a2b24dc73a6a7f2bbc45e20373dda1) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 3ada9f66e2..c2f01ce5b4 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -25,6 +25,7 @@ #include "registry.h" #include "lib/cmdline/popt_common.h" #include "system/filesys.h" +#include "librpc/gen_ndr/winreg.h" /* * Routines to parse a REGEDIT4 file -- cgit From 02b3abec25ed0b303906c5dae9dd527171762d9a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 3 Sep 2005 17:17:30 +0000 Subject: r10007: Merge data_blk and data_len member of registry_value into a DATA_BLOB. Fix handling of REG_DWORD in the LDB backend. Fix a couple of warnings (This used to be commit 709fdc7ebf5a77cfb50359fad978884777decc3b) --- source4/lib/registry/tools/regpatch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index c2f01ce5b4..5f7d4376d4 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -704,9 +704,11 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd DEBUG(0, ("Error removing value '%s'\n", val->name)); } modified = True; - } - else { - if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, val->val, strlen(val->val)))) { + } else { + DATA_BLOB blob; + blob.data = (uint8_t *)val->val; + blob.length = strlen(val->val); + if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, blob))) { DEBUG(0, ("Error adding new value '%s'\n", val->name)); continue; } -- cgit From ff7342a4ad1cc1ac8571c86466c197b6a8fa6b41 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Sep 2005 14:47:19 +0000 Subject: r10026: Move registry header file to lib/registry Add support for showing security descriptor in regshell Add support for saving files in NT4 registry backend (This used to be commit 47cecd4726e6568f1aafb404646d2664f630a9bb) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 5f7d4376d4..887f53df37 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -22,7 +22,7 @@ #include "includes.h" #include "dynconfig.h" -#include "registry.h" +#include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "system/filesys.h" #include "librpc/gen_ndr/winreg.h" -- cgit From 4abb4797613868e518baafb5f3618e78f67ac05c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Sep 2005 19:56:21 +0000 Subject: r10588: Remove more unused files, macros (This used to be commit d2f80c0457f7404b2cac9df59a400130e9ad025f) --- source4/lib/registry/tools/regpatch.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 887f53df37..98e6c0ff5d 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -156,10 +156,13 @@ static void print_line(struct cmd_line *cl) */ static struct cmd_line *get_cmd_line(int fd) { - CMD_LINE *cl = smb_xmalloc_p(CMD_LINE); + CMD_LINE *cl = malloc_p(CMD_LINE); int i = 0, rc; uint8_t ch; + if (!cl) + return NULL; + cl->len = INIT_ALLOC; /* @@ -447,7 +450,9 @@ static CMD *regedit4_get_cmd(int fd) struct cmd_line *cl = NULL; struct val_spec_list *vl = NULL; - cmd = smb_xmalloc_p(struct command_s); + cmd = malloc_p(struct command_s); + if (!cmd) + return NULL; cmd->cmd = CMD_NONE; cmd->key = NULL; @@ -490,7 +495,9 @@ static CMD *regedit4_get_cmd(int fd) * There could be a \ on the end which we need to * handle at some time */ - vl = smb_xmalloc_p(struct val_spec_list); + vl = malloc_p(struct val_spec_list); + if (!vl) + return NULL; vl->next = NULL; vl->val = NULL; vl->name = parse_value(cl, &vl->type, &vl->val); @@ -609,7 +616,9 @@ static CMD_FILE *cmd_file_create(const char *file) return NULL; } - tmp = smb_xmalloc_p(CMD_FILE); + tmp = malloc_p(CMD_FILE); + if (!tmp) + return NULL; /* * Let's fill in some of the fields; -- cgit From 5e7a0fb5349422cfb782c0348f98505011d27391 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Sep 2005 11:51:06 +0000 Subject: r10604: Put in the new registry "patchfile" code (similar to ldif for LDB); not finished yet. (This used to be commit b405b27ba4bf4ddbaff9ca58926d94d1b2fd09f6) --- source4/lib/registry/tools/regpatch.c | 741 +--------------------------------- 1 file changed, 11 insertions(+), 730 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 98e6c0ff5d..eca14741a5 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -2,8 +2,7 @@ Unix SMB/CIFS implementation. simple registry frontend - Copyright (C) 2002, Richard Sharpe, rsharpe@richardsharpe.com - Copyright (C) 2004, Jelmer Vernooij, jelmer@samba.org + Copyright (C) 2004-2005 Jelmer Vernooij, jelmer@samba.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,737 +26,14 @@ #include "system/filesys.h" #include "librpc/gen_ndr/winreg.h" -/* - * Routines to parse a REGEDIT4 file - * - * The file consists of: - * - * REGEDIT4 - * \[[-]key-path\]\n - * * - * - * Format: - * [cmd:]name=type:value - * - * cmd = a|d|c|add|delete|change|as|ds|cs - * - * There can be more than one key-path and value-spec. - * - * Since we want to support more than one type of file format, we - * construct a command-file structure that keeps info about the command file - */ - -#define FMT_UNREC -1 -#define FMT_REGEDIT4 0 -#define FMT_EDITREG1_1 1 - -#define FMT_STRING_REGEDIT4 "REGEDIT4" -#define FMT_STRING_EDITREG1_0 "EDITREG1.0" - -#define CMD_NONE 0 -#define CMD_ADD_KEY 1 -#define CMD_DEL_KEY 2 - -#define CMD_KEY 1 -#define CMD_VAL 2 - -typedef struct val_spec_list { - struct val_spec_list *next; - char *name; - int type; - char *val; /* Kept as a char string, really? */ -} VAL_SPEC_LIST; - -typedef struct command_s { - int cmd; - char *key; - int val_count; - VAL_SPEC_LIST *val_spec_list, *val_spec_last; -} CMD; - -typedef struct cmd_line { - int len, line_len; - char *line; -} CMD_LINE; - -static void free_val_spec_list(VAL_SPEC_LIST *vl) -{ - if (!vl) return; - if (vl->name) free(vl->name); - if (vl->val) free(vl->val); - free(vl); - -} - -/* - * Some routines to handle lines of info in the command files - */ -static void skip_to_eol(int fd) -{ - int rc; - char ch = 0; - - while ((rc = read(fd, &ch, 1)) == 1) { - if (ch == 0x0A) return; - } - if (rc < 0) { - DEBUG(0, ("Could not read file descriptor: %d, %s\n", - fd, strerror(errno))); - exit(1); - } -} - -static void free_cmd(CMD *cmd) -{ - if (!cmd) return; - - while (cmd->val_spec_list) { - VAL_SPEC_LIST *tmp; - - tmp = cmd->val_spec_list; - cmd->val_spec_list = tmp->next; - free(tmp); - } - - free(cmd); - -} - -static void free_cmd_line(CMD_LINE *cmd_line) -{ - if (cmd_line) { - if (cmd_line->line) free(cmd_line->line); - free(cmd_line); - } -} - -static void print_line(struct cmd_line *cl) -{ - char *pl; - - if (!cl) return; - - pl = smb_xmalloc(cl->line_len + 1); - - strncpy(pl, cl->line, cl->line_len); - pl[cl->line_len] = 0; - - fprintf(stdout, "%s\n", pl); - free(pl); -} - -#define INIT_ALLOC 10 - -/* - * Read a line from the input file. - * NULL returned when EOF and no chars read - * Otherwise we return a cmd_line * - * Exit if other errors - */ -static struct cmd_line *get_cmd_line(int fd) -{ - CMD_LINE *cl = malloc_p(CMD_LINE); - int i = 0, rc; - uint8_t ch; - - if (!cl) - return NULL; - - cl->len = INIT_ALLOC; - - /* - * Allocate some space for the line. We extend later if needed. - */ - - cl->line = (char *)smb_xmalloc(INIT_ALLOC); - - /* - * Now read in the chars to EOL. Don't store the EOL in the - * line. What about CR? - */ - - while ((rc = read(fd, &ch, 1)) == 1 && ch != '\n') { - if (ch == '\r') continue; /* skip CR */ - if (i == cl->len-1) { - /* - * Allocate some more memory - */ - if ((cl->line = realloc(cl->line, cl->len + INIT_ALLOC)) == NULL) { - DEBUG(0, ("Unable to realloc space for line: %s\n", - strerror(errno))); - exit(1); - } - cl->len += INIT_ALLOC; - } - cl->line[i] = ch; - i++; - } - - /* read 0 and we were at loc'n 0, return NULL */ - if (rc == 0 && i == 0) { - free_cmd_line(cl); - return NULL; - } - - cl->line[i] = '\0'; - cl->line_len = i; - - return cl; - -} - -/* - * parse_value: parse out a value. We pull it apart as: - * - * ::= =: - * - * ::= char-string-without-spaces | '"' char-string '"' - * - * If it parsed OK, return the as a string, and the - * value type and value-string in parameters. - * - * The value name can be empty. There can only be one empty name in - * a list of values. A value of - removes the value entirely. - */ - -static char *parse_name(char *nstr) -{ - int len = 0, start = 0; - if (!nstr) return NULL; - - len = strlen(nstr); - - while (len && nstr[len - 1] == ' ') len--; - - nstr[len] = 0; /* Trim any spaces ... if there were none, doesn't matter */ - - /* - * Beginning and end should be '"' or neither should be so - */ - if ((nstr[0] == '"' && nstr[len - 1] != '"') || - (nstr[0] != '"' && nstr[len - 1] == '"')) - return NULL; - - if (nstr[0] == '"') { - start = 1; - len -= 2; - } - - return strndup(&nstr[start], len); -} - -static int parse_value_type(char *tstr) -{ - int len = strlen(tstr); - - while (len && tstr[len - 1] == ' ') len--; - tstr[len] = 0; - - if (strcmp(tstr, "REG_DWORD") == 0) - return REG_DWORD; - else if (strcmp(tstr, "dword") == 0) - return REG_DWORD; - else if (strcmp(tstr, "REG_EXPAND_SZ") == 0) - return REG_EXPAND_SZ; - else if (strcmp(tstr, "REG_BIN") == 0) - return REG_BINARY; - else if (strcmp(tstr, "REG_SZ") == 0) - return REG_SZ; - else if (strcmp(tstr, "REG_MULTI_SZ") == 0) - return REG_MULTI_SZ; - else if (strcmp(tstr, "-") == 0) - return REG_DELETE; - - return 0; -} - -static char *parse_val_str(char *vstr) -{ - - return strndup(vstr, strlen(vstr)); - -} - -static char *parse_value(struct cmd_line *cl, int *vtype, char **val) -{ - char *p1 = NULL, *p2 = NULL, *nstr = NULL, *tstr = NULL, *vstr = NULL; - - if (!cl || !vtype || !val) return NULL; - if (!cl->line[0]) return NULL; - - p1 = strdup(cl->line); - /* FIXME: Better return codes etc ... */ - if (!p1) return NULL; - p2 = strchr(p1, '='); - if (!p2) return NULL; - - *p2 = 0; p2++; /* Split into two strings at p2 */ - - /* Now, parse the name ... */ - - nstr = parse_name(p1); - if (!nstr) goto error; - - /* Now, split the remainder and parse on type and val ... */ - - tstr = p2; - while (*tstr == ' ') tstr++; /* Skip leading white space */ - p2 = strchr(p2, ':'); - - if (p2) { - *p2 = 0; p2++; /* split on the : */ - } - - *vtype = parse_value_type(tstr); - - if (!vtype) goto error; - - if (!p2 || !*p2) return nstr; - - /* Now, parse the value string. It should return a newly malloc'd string */ - - while (*p2 == ' ') p2++; /* Skip leading space */ - vstr = parse_val_str(p2); - - if (!vstr) goto error; - - *val = vstr; - - return nstr; - - error: - if (p1) free(p1); - if (nstr) free(nstr); - if (vstr) free(vstr); - return NULL; -} - -/* - * Parse out a key. Look for a correctly formatted key [...] - * and whether it is a delete or add? A delete is signalled - * by a - in front of the key. - * Assumes that there are no leading and trailing spaces - */ - -static char *parse_key(struct cmd_line *cl, int *cmd) -{ - int start = 1; - char *tmp; - - if (cl->line[0] != '[' || - cl->line[cl->line_len - 1] != ']') return NULL; - if (cl->line_len == 2) return NULL; - *cmd = CMD_ADD_KEY; - if (cl->line[1] == '-') { - if (cl->line_len == 3) return NULL; - start = 2; - *cmd = CMD_DEL_KEY; - } - tmp = smb_xmalloc(cl->line_len - 1 - start + 1); - strncpy(tmp, &cl->line[start], cl->line_len - 1 - start); - tmp[cl->line_len - 1 - start] = 0; - return tmp; -} - -/* - * Parse a line to determine if we have a key or a value - * We only check for key or val ... - */ - -static int parse_line(struct cmd_line *cl) -{ - - if (!cl || cl->len == 0) return 0; - - if (cl->line[0] == '[') /* No further checking for now */ - return CMD_KEY; - else - return CMD_VAL; -} - -/* - * We seek to offset 0, read in the required number of bytes, - * and compare to the correct value. - * We then seek back to the original location - */ -static int regedit4_file_type(int fd) -{ - int cur_ofs = 0; - char desc[9]; - - cur_ofs = lseek(fd, 0, SEEK_CUR); /* Get current offset */ - if (cur_ofs < 0) { - DEBUG(0, ("Unable to get current offset: (%d) %s\n", cur_ofs, strerror(errno))); - exit(1); /* FIXME */ - } - - if (cur_ofs) { - lseek(fd, 0, SEEK_SET); - } - - if (read(fd, desc, 8) < 8) { - DEBUG(0, ("Unable to read command file format\n")); - exit(2); /* FIXME */ - } - - desc[8] = 0; - - if (strcmp(desc, FMT_STRING_REGEDIT4) == 0) { - if (cur_ofs) { - lseek(fd, cur_ofs, SEEK_SET); - } else { - skip_to_eol(fd); - } - return FMT_REGEDIT4; - } - - return FMT_UNREC; -} - -/* - * Run though the data in the line and strip anything after a comment - * char. - */ -static void strip_comment(struct cmd_line *cl) -{ - int i; - - if (!cl) return; - - for (i = 0; i < cl->line_len; i++) { - if (cl->line[i] == ';') { - cl->line[i] = '\0'; - cl->line_len = i; - return; - } - } -} - -/* - * Get a command ... This consists of possibly multiple lines: - * [key] - * values* - * possibly Empty line - * - * value ::= =':' - * is some path, possibly enclosed in quotes ... - * We alctually look for the next key to terminate a previous key - * if == '-', then it is a delete type. - */ -static CMD *regedit4_get_cmd(int fd) -{ - struct command_s *cmd = NULL; - struct cmd_line *cl = NULL; - struct val_spec_list *vl = NULL; - - cmd = malloc_p(struct command_s); - if (!cmd) - return NULL; - - cmd->cmd = CMD_NONE; - cmd->key = NULL; - cmd->val_count = 0; - cmd->val_spec_list = cmd->val_spec_last = NULL; - while ((cl = get_cmd_line(fd))) { - - /* - * If it is an empty command line, and we already have a key - * then exit from here ... FIXME: Clean up the parser - */ - - if (cl->line_len == 0 && cmd->key) { - free_cmd_line(cl); - break; - } - - strip_comment(cl); /* remove anything beyond a comment char */ - trim_string(cl->line, " \t", " \t"); - - if (!cl->line[0]) { /* An empty line */ - free_cmd_line(cl); - } - else { /* Else, non-empty ... */ - /* - * Parse out the bits ... - */ - switch (parse_line(cl)) { - case CMD_KEY: - if ((cmd->key = parse_key(cl, &cmd->cmd)) == NULL) { - DEBUG(0, ("Error parsing key from line: ")); - print_line(cl); - DEBUG(0, ("\n")); - } - break; - - case CMD_VAL: - /* - * We need to add the value stuff to the list - * There could be a \ on the end which we need to - * handle at some time - */ - vl = malloc_p(struct val_spec_list); - if (!vl) - return NULL; - vl->next = NULL; - vl->val = NULL; - vl->name = parse_value(cl, &vl->type, &vl->val); - if (!vl->name) goto error; - if (cmd->val_spec_list == NULL) { - cmd->val_spec_list = cmd->val_spec_last = vl; - } - else { - cmd->val_spec_last->next = vl; - cmd->val_spec_last = vl; - } - cmd->val_count++; - break; - - default: - DEBUG(0, ("Unrecognized line in command file: \n")); - print_line(cl); - break; - } - } - - } - if (!cmd->cmd) goto error; /* End of file ... */ - - return cmd; - - error: - if (vl) free(vl); - if (cmd) free_cmd(cmd); - return NULL; -} - -static int regedit4_exec_cmd(CMD *cmd) -{ - - return 0; -} - -static int editreg_1_0_file_type(int fd) -{ - int cur_ofs = 0; - char desc[11]; - - cur_ofs = lseek(fd, 0, SEEK_CUR); /* Get current offset */ - if (cur_ofs < 0) { - DEBUG(0, ("Unable to get current offset: %s\n", strerror(errno))); - exit(1); /* FIXME */ - } - - if (cur_ofs) { - lseek(fd, 0, SEEK_SET); - } - - if (read(fd, desc, 10) < 10) { - DEBUG(0, ("Unable to read command file format\n")); - exit(2); /* FIXME */ - } - - desc[10] = 0; - - if (strcmp(desc, FMT_STRING_EDITREG1_0) == 0) { - lseek(fd, cur_ofs, SEEK_SET); - return FMT_REGEDIT4; - } - - return FMT_UNREC; -} - -static CMD *editreg_1_0_get_cmd(int fd) +int main(int argc, char **argv) { - return NULL; -} - -static int editreg_1_0_exec_cmd(CMD *cmd) -{ - - return -1; -} - -typedef struct command_ops_s { - int type; - int (*file_type)(int fd); - CMD *(*get_cmd)(int fd); - int (*exec_cmd)(CMD *cmd); -} CMD_OPS; - -static CMD_OPS default_cmd_ops[] = { - {0, regedit4_file_type, regedit4_get_cmd, regedit4_exec_cmd}, - {1, editreg_1_0_file_type, editreg_1_0_get_cmd, editreg_1_0_exec_cmd}, - {-1, NULL, NULL, NULL} -}; - -typedef struct command_file_s { - char *name; - int type, fd; - CMD_OPS cmd_ops; -} CMD_FILE; - -/* - * Create a new command file structure - */ - -static CMD_FILE *cmd_file_create(const char *file) -{ - CMD_FILE *tmp; - struct stat sbuf; - int i = 0; - - /* - * Let's check if the file exists ... - * No use creating the cmd_file structure if the file does not exist - */ - - if (stat(file, &sbuf) < 0) { /* Not able to access file */ - DEBUG(0,("Stat on %s failed\n", file)); - return NULL; - } - - tmp = malloc_p(CMD_FILE); - if (!tmp) - return NULL; - - /* - * Let's fill in some of the fields; - */ - - tmp->name = strdup(file); - - if ((tmp->fd = open(file, O_RDONLY, 666)) < 0) { - DEBUG(0,("Error opening %s\n", file)); - free(tmp); - return NULL; - } - - /* - * Now, try to find the format by indexing through the table - */ - while (default_cmd_ops[i].type != -1) { - if ((tmp->type = default_cmd_ops[i].file_type(tmp->fd)) >= 0) { - tmp->cmd_ops = default_cmd_ops[i]; - return tmp; - } - i++; - } - - /* - * If we got here, return NULL, as we could not figure out the type - * of command file. - * - * What about errors? - */ - - free(tmp); - DEBUG(0,("Unknown type\n")); - return NULL; -} - -/* - * Extract commands from the command file, and execute them. - * We pass a table of command callbacks for that - */ - -/* FIXME */ - -/* - * Main code from here on ... - */ - -/* - * key print function here ... - */ - -/* - * Sec Desc print functions - */ - -char *str_type(uint8_t type); - -static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd_file_name) -{ - CMD *cmd; - BOOL modified = False; - CMD_FILE *cmd_file = NULL; - TALLOC_CTX *mem_ctx = talloc_init("apply_cmd_file"); - struct registry_key *tmp = NULL; - WERROR error; - cmd_file = cmd_file_create(cmd_file_name); - - while ((cmd = cmd_file->cmd_ops.get_cmd(cmd_file->fd)) != NULL) { - - /* - * Now, apply the requests to the tree ... - */ - switch (cmd->cmd) { - case CMD_ADD_KEY: - error = reg_open_key_abs(mem_ctx, r, cmd->key, &tmp); - - /* If we found it, apply the other bits, else create such a key */ - if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) { - if(!W_ERROR_IS_OK(reg_key_add_abs(mem_ctx, r, cmd->key, 0, NULL, &tmp))) { - DEBUG(0, ("Error adding new key '%s'\n", cmd->key)); - continue; - } - modified = True; - } - - while (cmd->val_count) { - VAL_SPEC_LIST *val = cmd->val_spec_list; - - if (val->type == REG_DELETE) { - error = reg_del_value(tmp, val->name); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error removing value '%s'\n", val->name)); - } - modified = True; - } else { - DATA_BLOB blob; - blob.data = (uint8_t *)val->val; - blob.length = strlen(val->val); - if(!W_ERROR_IS_OK(reg_val_set(tmp, val->name, val->type, blob))) { - DEBUG(0, ("Error adding new value '%s'\n", val->name)); - continue; - } - modified = True; - } - - cmd->val_spec_list = val->next; - free_val_spec_list(val); - cmd->val_count--; - } - - break; - - case CMD_DEL_KEY: - /* - * Any value does not matter ... - * Find the key if it exists, and delete it ... - */ - - error = reg_key_del_abs(r, cmd->key); - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to delete key '%s'\n", cmd->key)); - continue; - } - modified = True; - break; - } - } - free_cmd(cmd); - - return modified; -} - - int main(int argc, char **argv) -{ - int opt; + int opt; poptContext pc; const char *patch; struct registry_context *h; const char *remote = NULL; + struct reg_diff *diff; WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP @@ -786,10 +62,15 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd } patch = poptGetArg(pc); - if(!patch) patch = "/dev/stdin"; poptFreeContext(pc); - nt_apply_reg_command_file(h, patch); + diff = reg_diff_load(NULL, patch); + if (!diff) { + fprintf(stderr, "Unable to load registry patch from `%s'\n", patch); + return 1; + } + + reg_diff_apply(diff, h); return 0; } -- cgit From 6aafed9600a3fa05932668c70fc0e20f3724dab6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 18:48:23 +0000 Subject: r12499: Move smb_build.h out of includes.h (This used to be commit c92ace494f92084ddf178626cdf392d151043bc7) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index eca14741a5..8f86d8a8f0 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -25,6 +25,7 @@ #include "lib/cmdline/popt_common.h" #include "system/filesys.h" #include "librpc/gen_ndr/winreg.h" +#include "smb_build.h" int main(int argc, char **argv) { -- cgit From 09c44f6cae89621871d2e5475b0c0f99c25804b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 21:58:31 +0000 Subject: r12500: Use init functions explicitly in a few more places. 'gensec' and 'librpc' are the only two subsystems left to convert. (This used to be commit f6bbc72996aeee8607fc583140fd60be0e06e969) --- source4/lib/registry/tools/regpatch.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 8f86d8a8f0..2cc1507b3e 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -46,6 +46,8 @@ int main(int argc, char **argv) regpatch_init_subsystems; + registry_init(); + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/lib/registry/tools/regpatch.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 2cc1507b3e..b8b8805486 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -20,11 +20,8 @@ */ #include "includes.h" -#include "dynconfig.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" -#include "system/filesys.h" -#include "librpc/gen_ndr/winreg.h" #include "smb_build.h" int main(int argc, char **argv) -- cgit From aa9f67163cd2df2a815ef585edad1951343b82c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 22:46:16 +0000 Subject: r12620: Get rid of automatically generated lists of init functions of subsystems. This allows Samba libraries to be used by other projects (and parts of Samba to be built as shared libraries). (This used to be commit 44f0aba715bfedc7e1ee3d07e9a101a91dbd84b3) --- source4/lib/registry/tools/regpatch.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index b8b8805486..6f5c79bc0e 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -22,7 +22,6 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" -#include "smb_build.h" int main(int argc, char **argv) { @@ -41,8 +40,6 @@ int main(int argc, char **argv) POPT_TABLEEND }; - regpatch_init_subsystems; - registry_init(); pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); -- cgit From f8fdbc967c774a1d62f87a534e4990d83ecc6b67 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 14:34:32 +0000 Subject: r13944: Yet another round of splitups. (This used to be commit f87debeb12cebd734b47314554ab671c9e06237e) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 6f5c79bc0e..713d4b32cc 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -22,6 +22,7 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" +#include "lib/registry/reg_backend_rpc.h" int main(int argc, char **argv) { -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/lib/registry/tools/regpatch.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 713d4b32cc..9392e66192 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "lib/registry/reg_backend_rpc.h" -- cgit From d64ccc01769ce274c74d8458f9ef81cdcc8986f6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 21 Mar 2006 01:30:22 +0000 Subject: r14599: Pass ACLs down the registry layer. (This used to be commit 6cdefd8945eee5513a6993350ea71f12d4dbd6fa) --- source4/lib/registry/tools/regpatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 9392e66192..74601d73f9 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -50,9 +50,9 @@ int main(int argc, char **argv) } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote, NULL); + error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else { - error = reg_open_local (&h); + error = reg_open_local (&h, NULL, cmdline_credentials); } if (W_ERROR_IS_OK(error)) { -- cgit From 47bf79eac5c5c23394778b7e20a5263be71a9c66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 01:34:04 +0000 Subject: r15370: Fix more dependencies for shared libs (This used to be commit 9a518661fbb76bf1c153afc6f581e888186dc165) --- source4/lib/registry/tools/regpatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 74601d73f9..6e584e90a8 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -42,13 +42,13 @@ int main(int argc, char **argv) POPT_TABLEEND }; - registry_init(); - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { } + registry_init(); + if (remote) { error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else { -- cgit From 873749f2189ecf1fbfdc681df4dd304a17716279 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 12:28:01 +0000 Subject: r18168: Use {NULL} rather than POPT_TABLEEND, which is not always available. (This used to be commit 8b622c5ded0732df0eaf9f6226f52a27b6eacd73) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 6e584e90a8..7ed246566c 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS - POPT_TABLEEND + { NULL } }; pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); -- cgit From 655b710204e7a7d8e486da7ba675fcbeed116fea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 16 Sep 2006 16:59:37 +0000 Subject: r18584: found one of the fd leaks. The registry backend was using a talloc(NULL, xxx) to allocate the registry context. That had two consequences 1) it was a massive memory leak, as all winreg operations leaked their entire context (including an open ldb database) every time 2) event_context_find() never found the exsting event context, so we used a new event context each time, which called epoll_create() each time, which caused a fd to be allocated (This used to be commit 1c0a3de39828b43149d8981fc7f10e7c8b59a392) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 7ed246566c..42cdac860b 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -52,7 +52,7 @@ int main(int argc, char **argv) if (remote) { error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else { - error = reg_open_local (&h, NULL, cmdline_credentials); + error = reg_open_local (NULL, &h, NULL, cmdline_credentials); } if (W_ERROR_IS_OK(error)) { -- cgit From 4f0c0997ce39ecb2920c1d52b03d77e1d50cd5bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 13 Mar 2007 22:03:04 +0000 Subject: r21834: Remove unnecessary includes (This used to be commit 7d10e192caa60b816466a9deddf736afd2445080) --- source4/lib/registry/tools/regpatch.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 42cdac860b..16fe4f498a 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -23,7 +23,6 @@ #include "lib/events/events.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" -#include "lib/registry/reg_backend_rpc.h" int main(int argc, char **argv) { -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/registry/tools/regpatch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 16fe4f498a..83ad5575ef 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From b409d4120f9ae451f93a2322267c0f346531d9f3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 15:16:40 +0000 Subject: r24667: Finally merge the registry improvements that Wilco Baan Hofman and I have been working on for at least half a year now. Contains the following improvements: * proper layering (finally!) for the registry library. Distinction is now made between 'real' backends (local, remote, wine, etc) and the low-level hive backends (regf, creg, ldb, ...) that are only used by the local registry backend * tests for all important hive and registry operations * re-enable RPC-WINREG tests (still needs more work though, as some return values aren't checked yet) * write support for REGF files * dir backend now supports setting/reading values, creating keys * support for storing security descriptors * remove CREG backend as it was incomplete, didn't match the data model and wasn't used at all anyway * support for parsing ADM files as used by the policy editor (see lib/policy) * support for parsing PREG files (format used by .POL files) * new streaming interface for registry diffs (improves speed and memory usage for regdiff/regpatch significantly) ... and fixes a large number of bugs in the registry code (This used to be commit 7a1eec6358bc863dfc671c542b7185d3e39d7b5a) --- source4/lib/registry/tools/regpatch.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 83ad5575ef..1e6d15a7af 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -2,7 +2,7 @@ Unix SMB/CIFS implementation. simple registry frontend - Copyright (C) 2004-2005 Jelmer Vernooij, jelmer@samba.org + Copyright (C) 2004-2007 Jelmer Vernooij, jelmer@samba.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ #include "lib/events/events.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" +#include "lib/registry/tools/common.h" +#include "lib/registry/patchfile.h" int main(int argc, char **argv) { @@ -29,12 +31,12 @@ int main(int argc, char **argv) poptContext pc; const char *patch; struct registry_context *h; + const char *file = NULL; const char *remote = NULL; - struct reg_diff *diff; - WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, + {"file", 'F', POPT_ARG_STRING, &file, 0, "file path", NULL }, POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS { NULL } @@ -45,29 +47,24 @@ int main(int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { } - registry_init(); - if (remote) { - error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); + h = reg_common_open_remote (remote, cmdline_credentials); } else { - error = reg_open_local (NULL, &h, NULL, cmdline_credentials); + h = reg_common_open_local (cmdline_credentials); } - - if (W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error: %s\n", win_errstr(error)); + + if (h == NULL) return 1; - } patch = poptGetArg(pc); - poptFreeContext(pc); - - diff = reg_diff_load(NULL, patch); - if (!diff) { - fprintf(stderr, "Unable to load registry patch from `%s'\n", patch); + if (patch == NULL) { + poptPrintUsage(pc, stderr, 0); return 1; } - reg_diff_apply(diff, h); + poptFreeContext(pc); + + reg_diff_apply(patch, h); return 0; } -- cgit From 33032276f532f5344d56ca6c436befb2e3b74fc5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 10 Oct 2007 12:27:24 +0200 Subject: r25603: More reformat. Guenther (This used to be commit 176614423ea57e853211c43b9853203243c6a978) --- source4/lib/registry/tools/regpatch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 1e6d15a7af..35f12c7e62 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -1,19 +1,19 @@ -/* +/* Unix SMB/CIFS implementation. simple registry frontend - + Copyright (C) 2004-2007 Jelmer Vernooij, jelmer@samba.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -52,10 +52,10 @@ int main(int argc, char **argv) } else { h = reg_common_open_local (cmdline_credentials); } - + if (h == NULL) return 1; - + patch = poptGetArg(pc); if (patch == NULL) { poptPrintUsage(pc, stderr, 0); -- cgit From 6c999cd12344f2bb8b1d2941210b4c205b3e0aad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 22:32:11 +0100 Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. (This used to be commit 5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521) --- source4/lib/registry/tools/regpatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 35f12c7e62..2f2cf789a9 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" #include "lib/registry/patchfile.h" +#include "param/param.h" int main(int argc, char **argv) { @@ -50,7 +51,7 @@ int main(int argc, char **argv) if (remote) { h = reg_common_open_remote (remote, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials); + h = reg_common_open_local (cmdline_credentials, global_loadparm); } if (h == NULL) -- cgit From bca631be1f4cefeec3d64cd552ec6d9ee9cc1971 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 03:01:41 +0100 Subject: r26329: Fix more loadparm_context references. Only about a 100 left now. (This used to be commit ddf233346d848e91bc6a6a572f0f6120540503b7) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 2f2cf789a9..441138832e 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) } if (remote) { - h = reg_common_open_remote (remote, cmdline_credentials); + h = reg_common_open_remote (remote, global_loadparm, cmdline_credentials); } else { h = reg_common_open_local (cmdline_credentials, global_loadparm); } -- cgit From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/lib/registry/tools/regpatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 441138832e..ddbedce18a 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -49,9 +49,9 @@ int main(int argc, char **argv) } if (remote) { - h = reg_common_open_remote (remote, global_loadparm, cmdline_credentials); + h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials, global_loadparm); + h = reg_common_open_local (cmdline_credentials, cmdline_lp_ctx); } if (h == NULL) -- cgit From 670918f916cb881d4cc591516c70bafe4e39ba45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Dec 2007 05:02:48 -0600 Subject: r26563: Fix reg_diff_apply argument order. (This used to be commit cfffd0357ee4c4bb3f3c9adb051eeee1bbac526a) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index ddbedce18a..71837d1807 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) poptFreeContext(pc); - reg_diff_apply(patch, h); + reg_diff_apply(h, patch); return 0; } -- cgit From 4e5e7a7c688d8a065994cb16fb1da7581bab081a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 16:47:17 +0200 Subject: Reintroduce header previously autogenerated but ignored by git. Also fixed extra include in regpatch. (This used to be commit 0e371cf169e9a607fcbb3e65437ab9413935dd52) --- source4/lib/registry/tools/regpatch.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 71837d1807..98443e6456 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -23,7 +23,6 @@ #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" -#include "lib/registry/patchfile.h" #include "param/param.h" int main(int argc, char **argv) -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/lib/registry/tools/regpatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 98443e6456..9285459d85 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" #include "param/param.h" +#include "events/events.h" int main(int argc, char **argv) { @@ -33,6 +34,7 @@ int main(int argc, char **argv) struct registry_context *h; const char *file = NULL; const char *remote = NULL; + struct event_context *ev; struct poptOption long_options[] = { POPT_AUTOHELP {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, @@ -47,10 +49,12 @@ int main(int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { } + ev = event_context_init(NULL); + if (remote) { h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials, cmdline_lp_ctx); + h = reg_common_open_local (cmdline_credentials, ev, cmdline_lp_ctx); } if (h == NULL) -- cgit From 2daf2897d5c70c0efbeba9b827c62700b9a9537c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 13:00:53 -0400 Subject: Use a custom init function for samba4 that sets a samba4 specific debug function. By default do not debug, this is the most appropriate action for a library as we cannot assume what stderr is use for in the main app. The main app is responsible to set ev_debug_stderr if they so desire. (This used to be commit e566a2f308ac6fb4b526a744f7059b565670aea5) --- source4/lib/registry/tools/regpatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 9285459d85..1170fbadb4 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { } - ev = event_context_init(NULL); + ev = s4_event_context_init(NULL); if (remote) { h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); -- cgit From 3911808323c964c36c2639f68d59d7aca1a2a96b Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Tue, 9 Sep 2008 18:03:54 +0200 Subject: Fix up the "reg_common_open_remote" call This fixes up the "reg_common_open_remote" call because it didn't work anymore without the event context. (This used to be commit 42ab865fc937a625d1eece45abe96bf354ddff8b) --- source4/lib/registry/tools/regpatch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regpatch.c') diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 1170fbadb4..add59a5e64 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) struct registry_context *h; const char *file = NULL; const char *remote = NULL; - struct event_context *ev; + struct event_context *ev_ctx; struct poptOption long_options[] = { POPT_AUTOHELP {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, @@ -49,12 +49,12 @@ int main(int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { } - ev = s4_event_context_init(NULL); + ev_ctx = s4_event_context_init(NULL); if (remote) { - h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); + h = reg_common_open_remote (remote, ev_ctx, cmdline_lp_ctx, cmdline_credentials); } else { - h = reg_common_open_local (cmdline_credentials, ev, cmdline_lp_ctx); + h = reg_common_open_local (cmdline_credentials, ev_ctx, cmdline_lp_ctx); } if (h == NULL) -- cgit