Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libeconf for openSUSE:Factory checked in at 2022-05-01 18:53:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libeconf (Old) and /work/SRC/openSUSE:Factory/.libeconf.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "libeconf" Sun May 1 18:53:18 2022 rev:15 rq:973278 version:0.4.6+git20220427.3016f4e Changes: -------- --- /work/SRC/openSUSE:Factory/libeconf/libeconf.changes 2022-04-08 22:45:21.319381172 +0200 +++ /work/SRC/openSUSE:Factory/.libeconf.new.1538/libeconf.changes 2022-05-01 18:53:21.231149891 +0200 @@ -1,0 +2,11 @@ +Wed Apr 27 22:10:35 UTC 2022 - schubi@suse.com + +- Update to version 0.4.6+git20220427.3016f4e: + * econftool: + ** Parsing error: Reporting file and line nr. + ** --delimeters=spaces Taking all kind of spaces for delimiter + * libeconf: + Fixed bsc#1198165: Parsing files correctly which have space characters + AND none space characters as delimiters. + +------------------------------------------------------------------- Old: ---- libeconf-0.4.5+git20220406.c9658f2.tar.xz New: ---- libeconf-0.4.6+git20220427.3016f4e.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libeconf.spec ++++++ --- /var/tmp/diff_new_pack.Sr17we/_old 2022-05-01 18:53:21.699150325 +0200 +++ /var/tmp/diff_new_pack.Sr17we/_new 2022-05-01 18:53:21.707150332 +0200 @@ -18,7 +18,7 @@ %define lname libeconf0 Name: libeconf -Version: 0.4.5+git20220406.c9658f2 +Version: 0.4.6+git20220427.3016f4e Release: 0 Summary: Enhanced config file parser ala systemd License: LGPL-2.1-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Sr17we/_old 2022-05-01 18:53:21.735150358 +0200 +++ /var/tmp/diff_new_pack.Sr17we/_new 2022-05-01 18:53:21.739150363 +0200 @@ -1,7 +1,7 @@ <services> <service name="tar_scm" mode="disabled"> - <param name="version">0.4.5</param> - <param name="versionformat">0.4.5+git%cd.%h</param> + <param name="version">0.4.6</param> + <param name="versionformat">0.4.6+git%cd.%h</param> <param name="url">https://github.com/openSUSE/libeconf.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Sr17we/_old 2022-05-01 18:53:21.759150381 +0200 +++ /var/tmp/diff_new_pack.Sr17we/_new 2022-05-01 18:53:21.763150384 +0200 @@ -1,7 +1,7 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/openSUSE/libeconf.git</param> - <param name="changesrevision">c9658f240b5c6d8d85f52f5019e47bc29c88b83f</param> + <param name="changesrevision">3016f4e2fde7e27992251a36157e964d9c076c33</param> </service> </servicedata> (No newline at EOF) ++++++ libeconf-0.4.5+git20220406.c9658f2.tar.xz -> libeconf-0.4.6+git20220427.3016f4e.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/NEWS new/libeconf-0.4.6+git20220427.3016f4e/NEWS --- old/libeconf-0.4.5+git20220406.c9658f2/NEWS 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/NEWS 2022-04-27 23:57:10.000000000 +0200 @@ -1,3 +1,18 @@ +Version 0.4.6 +* econftool: + ** Parsing error: Reporting file and line nr. + ** --delimeters=spaces Taking all kind of spaces for delimiter +* libeconf: + Fixed bnc#1198165: Parsing files correctly which have space characters + AND none space characters as delimiters. + +Version 0.4.5 +* econftool: + ** New call "syntax" for checking the configuration files only. + Returns an error string with line number if an error occurs. + ** New options "--comment" and "--delimeters" + ** Parsing one file only if needed. + Version 0.4.4 * Fixed i586 build Version 0.4.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/doc/man/econftool.8 new/libeconf-0.4.6+git20220427.3016f4e/doc/man/econftool.8 --- old/libeconf-0.4.5+git20220406.c9658f2/doc/man/econftool.8 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/doc/man/econftool.8 2022-04-27 23:57:10.000000000 +0200 @@ -35,6 +35,18 @@ .B OPTIONS -y, --yes: Assumes yes for all prompts and runs non-interactively. + +.SH general OPTIONS +.TP +.B --comment <character> + Character which starts a comment. ('#' default). + +.TP +.B --delimiters <string> + Characters which separates key/value entries. ("=" default). + e.g. --delimiters="= \t" + e.g. --delimiters=spaces regarding all spaces + .SH "SEE ALSO" .PP libeconf\& diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/include/libeconf.h new/libeconf-0.4.6+git20220427.3016f4e/include/libeconf.h --- old/libeconf-0.4.5+git20220406.c9658f2/include/libeconf.h 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/include/libeconf.h 2022-04-27 23:57:10.000000000 +0200 @@ -107,7 +107,9 @@ * * @param result content of parsed file * @param file_name absolute path of parsed file - * @param delim delimiters of key/value e.g. "\t =" + * @param delim delimiters of key/value e.g. "\t =". + * If delim contains space characters AND none space characters, + * multiline values are not parseable. * @param comment array of characters which define the start of a comment * @return econf_err ECONF_SUCCESS or error code * @@ -170,6 +172,8 @@ * @param project_name basename of the configuration file * @param config_suffix suffix of the configuration file. Can also be NULL. * @param delim delimiters of key/value e.g. "\t =" + * If delim contains space characters AND none space characters, + * multiline values are not parseable. * @param comment array of characters which define the start of a comment * @return econf_err ECONF_SUCCESS or error code * @@ -211,6 +215,8 @@ * @param project_name basename of the configuration file * @param config_suffix suffix of the configuration file. Can also be NULL. * @param delim delimiters of key/value e.g. "\t =" + * If delim contains space characters AND none space characters, + * multiline values are not parseable. * @param comment array of characters which define the start of a comment * @return econf_err ECONF_SUCCESS or error code * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/lib/getfilecontents.c new/libeconf-0.4.6+git20220427.3016f4e/lib/getfilecontents.c --- old/libeconf-0.4.5+git20220406.c9658f2/lib/getfilecontents.c 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/lib/getfilecontents.c 2022-04-27 23:57:10.000000000 +0200 @@ -369,45 +369,51 @@ *data++ = '\0'; } - /* Checking and adding multiline entries which are - * not defined by a beginning quote in the line before. - */ - bool found_delim = delim_seen; - if (!found_delim) - { - /* searching the rest of the string for delimiters */ - char *c = data; - while (*c && !(strchr(delim, *c) != NULL)) - c++; - if (*c) - found_delim = true; - } - if (!found_delim && - /* Entry has already been found */ - ef->length > 0 && - /* The Entry must be the next line. Otherwise it is a new one */ - ef->file_entry[ef->length-1].line_number+1 == line) - { - /* removing comments */ - for (size_t i = 0; i < strlen(comment); i++) { - char *pt = strchr(org_buf, comment[i]); - if (pt) - *pt = '\0'; + if (!has_wsp || !has_nonwsp) { + /* Multiline entries make no sense if the delimiters are + * whitespaces AND none whitespaces. + */ + + /* Checking and adding multiline entries which are + * not defined by a beginning quote in the line before. + */ + bool found_delim = delim_seen; + if (!found_delim) + { + /* searching the rest of the string for delimiters */ + char *c = data; + while (*c && !(strchr(delim, *c) != NULL)) + c++; + if (*c) + found_delim = true; + } + if (!found_delim && + /* Entry has already been found */ + ef->length > 0 && + /* The Entry must be the next line. Otherwise it is a new one */ + ef->file_entry[ef->length-1].line_number+1 == line) + { + /* removing comments */ + for (size_t i = 0; i < strlen(comment); i++) { + char *pt = strchr(org_buf, comment[i]); + if (pt) + *pt = '\0'; + } + /* removing \n at the end of the line */ + if( org_buf[strlen(org_buf)-1] == '\n' ) + org_buf[strlen(org_buf)-1] = 0; + retval = store(ef, current_group, name, org_buf, line, + current_comment_before_key, current_comment_after_value, + false, /* Quotes does not matter in the following lines */ + true /* appending entry */); + free(current_comment_before_key); + current_comment_before_key = NULL; + free(current_comment_after_value); + current_comment_after_value = NULL; + if (retval) + goto out; + continue; } - /* removing \n at the end of the line */ - if( org_buf[strlen(org_buf)-1] == '\n' ) - org_buf[strlen(org_buf)-1] = 0; - retval = store(ef, current_group, name, org_buf, line, - current_comment_before_key, current_comment_after_value, - false, /* Quotes does not matter in the following lines */ - true /* appending entry */); - free(current_comment_before_key); - current_comment_before_key = NULL; - free(current_comment_after_value); - current_comment_after_value = NULL; - if (retval) - goto out; - continue; } /* Go on. It is not an multiline entry */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/meson.build new/libeconf-0.4.6+git20220427.3016f4e/meson.build --- old/libeconf-0.4.5+git20220406.c9658f2/meson.build 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/meson.build 2022-04-27 23:57:10.000000000 +0200 @@ -7,7 +7,7 @@ 'b_pie=true', 'warning_level=3',], license : 'MIT', - version : '0.4.4', + version : '0.4.6', ) cc = meson.get_compiler('c') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/tests/tst-logindefs1.c new/libeconf-0.4.6+git20220427.3016f4e/tests/tst-logindefs1.c --- old/libeconf-0.4.5+git20220406.c9658f2/tests/tst-logindefs1.c 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/tests/tst-logindefs1.c 2022-04-27 23:57:10.000000000 +0200 @@ -20,7 +20,7 @@ char *val; econf_err error; - if ((error = econf_readFile (&key_file, TESTSDIR"tst-logindefs1-data/etc/login.defs", " \t", "#"))) + if ((error = econf_readFile (&key_file, TESTSDIR"tst-logindefs1-data/etc/login.defs", "= \t", "#"))) { fprintf (stderr, "ERROR: couldn't read configuration file: %s\n", econf_errString(error)); return 1; @@ -43,6 +43,24 @@ return 1; } free (val); + + if ((error = econf_getStringValue (key_file, NULL, "ENV_SUPATH", &val))) + { + fprintf (stderr, "Error reading ENV_SUPATH: %s\n", + econf_errString(error)); + return 1; + } + else if (strlen(val) == 0) + { + fprintf (stderr, "ENV_SUPATH returns nothing!\n"); + return 1; + } + else if (strcmp (val, "PATH=/sbin:/bin:/usr/sbin:/usr/bin") != 0) + { + fprintf (stderr, "ENV_SUPATH returns wrong value: '%s'\n", val); + return 1; + } + free (val); if ((error = econf_getStringValue (key_file, "", "UMASK", &val))) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libeconf-0.4.5+git20220406.c9658f2/util/econftool.c new/libeconf-0.4.6+git20220427.3016f4e/util/econftool.c --- old/libeconf-0.4.5+git20220406.c9658f2/util/econftool.c 2022-04-06 17:23:40.000000000 +0200 +++ new/libeconf-0.4.6+git20220427.3016f4e/util/econftool.c 2022-04-27 23:57:10.000000000 +0200 @@ -77,7 +77,32 @@ fprintf(stderr, " -y, --yes: assumes yes for all prompts and runs non-interactively.\n\n"); fprintf(stderr, "\ngeneral Options:\n"); fprintf(stderr, "--comment <character>: Character which starts a comment. ('#' default).\n"); - fprintf(stderr, "--delimeters <string>: Characters which separates key/value entries. (\"=\" default).\n"); + fprintf(stderr, "--delimiters <string>: Characters which separates key/value entries. (\"=\" default).\n"); + fprintf(stderr, " e.g. --delimiters=\"= \\t\"\n"); + fprintf(stderr, " e.g. --delimiters=spaces regarding all spaces\n"); +} + +/** + * @brief Replace a substring of a string by another + * + * @param str source string + * @param orig search string + * @param rep replace string + */ +static char *replace_str(char *str, char *orig, char *rep) +{ + static char buffer[1024]; + char *p; + + if(!(p = strstr(str, orig))) + return str; + + strncpy(buffer, str, p-str); + buffer[p-str] = '\0'; + + sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig)); + + return buffer; } /** @@ -146,6 +171,21 @@ } /** + * @brief printing error with linenr and filename + */ +static void print_error(const econf_err error) +{ + char *filename = NULL; + uint64_t line_nr = 0; + + econf_errLocation( &filename, &line_nr); + fprintf(stderr, "%s (line %d): %s\n", filename, (int) line_nr, + econf_errString(error)); + free(filename); +} + + +/** * @brief printing header */ static void pr_header(void) @@ -177,8 +217,15 @@ /* show groups, keys and their value */ econf_error = econf_getGroups(key_file, &groupCount, &groups); if (econf_error) { - fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); - return econf_error; + if (econf_error != ECONF_NOGROUP) { + print_error(econf_error); + return econf_error; + } else { + /* no groups defined; generating an root entry */ + groups = calloc(1, sizeof(char*)); + groups[0] = NULL; + groupCount = 1; + } } for (size_t g = 0; g < groupCount; g++) { char **keys = NULL; @@ -186,15 +233,18 @@ econf_error = econf_getKeys(key_file, groups[g], &key_count, &keys); if (econf_error) { - fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); + print_error(econf_error); econf_free(keys); return econf_error; } - printf("%s\n", groups[g]); + + if (groups[g] != NULL) + printf("%s\n", groups[g]); + for (size_t k = 0; k < key_count; k++) { econf_error = econf_getExtValue(key_file, groups[g], keys[k], &value); if (econf_error) { - fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); + print_error(econf_error); econf_free(keys); return econf_error; } @@ -225,19 +275,19 @@ * will evtl. print all groups, keys and their values as * an application would see them. */ -static int econf_read(struct econf_file **key_file, const char *delimeters, const char *comment, const bool show) +static int econf_read(struct econf_file **key_file, const char *delimiters, const char *comment, const bool show) { econf_err econf_error; if (conf_filename[0] == '/') { /* reading one file only */ econf_error = econf_readFile(key_file, conf_filename, - delimeters, comment); + delimiters, comment); } else { econf_error = econf_readDirs(key_file, usr_root_dir, root_dir, conf_basename, - conf_suffix, delimeters, comment); + conf_suffix, delimiters, comment); } if (econf_error) { - fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); + print_error(econf_error); return -1; } if (show) { @@ -254,7 +304,7 @@ * (econf_readDirs) in hierarchical order and print all groups, * keys and their values. */ -static int econf_cat(const char *delimeters, const char *comment) +static int econf_cat(const char *delimiters, const char *comment) { econf_file **key_files; econf_err econf_error; @@ -268,9 +318,9 @@ econf_error = econf_readDirsHistory(&key_files, &size, usr_root_dir, root_dir, conf_basename, - conf_suffix, delimeters, comment); + conf_suffix, delimiters, comment); if (econf_error) { - fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); + print_error(econf_error); return -1; } @@ -289,7 +339,7 @@ * It then saves the edited in key_file_edit and deletes the tmpfile */ static int econf_edit_editor(struct econf_file **key_file_edit, struct econf_file **key_file, - const char *delimeters, const char *comment) + const char *delimiters, const char *comment) { econf_err econf_error; int wstatus; @@ -346,7 +396,7 @@ } while (!WIFEXITED(wstatus)); /* save edits from tmpfile_edit in key_file_edit */ - econf_error = econf_readFile(key_file_edit, path_tmpfile_edit, delimeters, comment); + econf_error = econf_readFile(key_file_edit, path_tmpfile_edit, delimiters, comment); if (econf_error) { fprintf(stderr, "%s\n", econf_errString(econf_error)); ret = -1; @@ -372,7 +422,7 @@ * TODO: * - Replace static values of the path with future libeconf API calls */ -static int econf_edit(struct econf_file **key_file, const char *delimeters, const char *comment) +static int econf_edit(struct econf_file **key_file, const char *delimiters, const char *comment) { econf_err econf_error; econf_file *key_file_edit = NULL; @@ -380,9 +430,9 @@ if (conf_filename[0] == '/') { /* reading one file only */ econf_error = econf_readFile(key_file, conf_filename, - delimeters, comment); + delimiters, comment); } else { - econf_error = econf_readDirs(key_file, usr_root_dir, root_dir, conf_basename, conf_suffix, delimeters, comment); + econf_error = econf_readDirs(key_file, usr_root_dir, root_dir, conf_basename, conf_suffix, delimiters, comment); } if (econf_error == ECONF_NOFILE) { @@ -398,7 +448,7 @@ return -1; } - if (econf_edit_editor(&key_file_edit, key_file, delimeters, comment)) { + if (econf_edit_editor(&key_file_edit, key_file, delimiters, comment)) { econf_free(key_file_edit); return -1; } @@ -554,7 +604,7 @@ bool is_root = false; bool use_homedir = false; char *comment = "#"; - char *delimeters = "="; + char *delimiters = "="; /* parse command line arguments. See getopt_long(3) */ int opt, nonopts; @@ -567,7 +617,7 @@ {"yes", no_argument, 0, 'y'}, {"use-home", no_argument, 0, 'u'}, {"comment", required_argument, 0, 'c'}, - {"delimeters", required_argument, 0, 'd'}, + {"delimiters", required_argument, 0, 'd'}, {0, 0, 0, 0 } }; @@ -592,7 +642,7 @@ comment = optarg; break; case 'd': - delimeters = optarg; + delimiters = optarg; break; case '?': default: @@ -612,8 +662,19 @@ usage(); return EXIT_FAILURE; } - /**** initialization ****/ + /* translating delimiters */ + if ( strcmp(delimiters, "spaces") == 0 ) { + delimiters = " \t\f\n\r\v"; + } else { + delimiters = replace_str(delimiters, "\\t", "\t"); + delimiters = replace_str(delimiters, "\\f", "\f"); + delimiters = replace_str(delimiters, "\\n", "\n"); + delimiters = replace_str(delimiters, "\\r", "\r"); + delimiters = replace_str(delimiters, "\\v", "\v"); + } + + /**** initialization ****/ /* basic write permission check */ is_root = getuid() == 0; @@ -671,9 +732,9 @@ int ret = 0; if (strcmp(argv[optind], "show") == 0) { - ret = econf_read(&key_file, delimeters, comment, true); + ret = econf_read(&key_file, delimiters, comment, true); } else if (strcmp(argv[optind], "syntax") == 0) { - ret = econf_read(&key_file, delimeters, comment, false); + ret = econf_read(&key_file, delimiters, comment, false); } else if (strcmp(argv[optind], "edit") == 0) { if (!is_root || use_homedir) { /* adjust path to home directory of the user.*/ @@ -687,11 +748,11 @@ conf_filename); } - ret = econf_edit(&key_file, delimeters, comment); + ret = econf_edit(&key_file, delimiters, comment); } else if (strcmp(argv[optind], "revert") == 0) { ret = econf_revert(is_root, use_homedir); } else if (strcmp(argv[optind], "cat") == 0) { - ret = econf_cat(delimeters, comment); + ret = econf_cat(delimiters, comment); } else { fprintf(stderr, "Unknown command!\n\n"); usage();