[pacman-dev] [RFC][PATCH] Introduce Include key globing for pacman.conf
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- diff -Nurp pacman-3.3.0.orig/src/pacman/pacman.c pacman-3.3.0/src/pacman/pacman.c --- pacman-3.3.0.orig/src/pacman/pacman.c 2009-08-01 20:07:42.000000000 +0200 +++ pacman-3.3.0/src/pacman/pacman.c 2009-09-10 21:11:03.000000000 +0200 @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,23 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_TILDE_CHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space\n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) { This patch addes the ability to use Include filenames containing wildcards and also expands the tilde to the homedir of the executing user. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- diff -Nurp pacman-3.3.0.orig/src/pacman/pacman.c pacman-3.3.0/src/pacman/pacman.c --- pacman-3.3.0.orig/src/pacman/pacman.c 2009-08-01 20:07:42.000000000 +0200 +++ pacman-3.3.0/src/pacman/pacman.c 2009-09-10 21:11:03.000000000 +0200 @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,23 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_TILDE_CHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space\n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user. Added a headercheck for glob.h to configure.ac Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- --- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes") # Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,23 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_TILDE_CHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space \n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user. Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- --- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes") # Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,24 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_TILDE_CHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space \n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } + globfree(&globbuf); /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
On Fri, Sep 11, 2009 at 10:51 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
Can you provide an use-case / examples justifying this ? I am not sure we want/need these features, and I am not sure it's a good idea to have non-static mirrors (depending on the user executing, depending on the files matching the glob, etc)
Hello Xavier, Am Freitag, den 11.09.2009, 11:17 +0200 schrieb Xavier:
On Fri, Sep 11, 2009 at 10:51 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
Can you provide an use-case / examples justifying this ?
we use it to add repos or options by installing files into /etc/pacman/conf.d/ with a name of testing.conf for a repo called testing for example and only add Include = /etc/pacman/conf.d/*.conf in /etc/pacman/pacman.conf.
I am not sure we want/need these features, and I am not sure it's a good idea to have non-static mirrors (depending on the user executing, depending on the files matching the glob, etc)
I thought of options like ShowSize and TotalDownload... But as pacman has to be executed by root for -S the tilde expanding looks like a pointless thing to do in the end... But glob could do it so it is there for free. But i don't get your point. Isn't the configuration for pacman a distro thing and the packagers of the pacman package should know what they do? If they don't want to use it on arch the don't have to add it to there configuration files. We use it for our inhouse cluster-distro, it's useful and it works good for us. Marc
Am Freitag, den 11.09.2009, 11:32 +0200 schrieb Marc - A. Dahlhaus [ Administration | Westermann GmbH ]:
Hello Xavier,
Am Freitag, den 11.09.2009, 11:17 +0200 schrieb Xavier:
On Fri, Sep 11, 2009 at 10:51 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards and also expands the tilde to the homedirectory of the executing user.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
Can you provide an use-case / examples justifying this ?
we use it to add repos or options by installing files into /etc/pacman/conf.d/ with a name of testing.conf for a repo called testing for example and only add
Include = /etc/pacman/conf.d/*.conf
in /etc/pacman/pacman.conf.
Forgot to add that this way the pacman.conf is decoupled of the repositories and can be replaced on updates even if a user added another repo. This was my main motivation in adding the support for globing here.
I am not sure we want/need these features, and I am not sure it's a good idea to have non-static mirrors (depending on the user executing, depending on the files matching the glob, etc)
I thought of options like ShowSize and TotalDownload...
But as pacman has to be executed by root for -S the tilde expanding looks like a pointless thing to do in the end... But glob could do it so it is there for free.
But i don't get your point.
Isn't the configuration for pacman a distro thing and the packagers of the pacman package should know what they do? If they don't want to use it on arch the don't have to add it to there configuration files.
We use it for our inhouse cluster-distro, it's useful and it works good for us.
Marc
-- Mit freundlichen Gruessen, Marc - A. Dahlhaus Administration Westermann GmbH Tel: 04252 399 87 Am Gaswerk 3 Fax: 04252 399 45 27305 Bruchhausen-Vilsen Mail: mad@wol.de Geschaeftsfuehrer: Hermann Westermann Handelsregister: Walsrode, HRB 110518
On Fri, Sep 11, 2009 at 11:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
Can you provide an use-case / examples justifying this ?
we use it to add repos or options by installing files into /etc/pacman/conf.d/ with a name of testing.conf for a repo called testing for example and only add
Include = /etc/pacman/conf.d/*.conf
in /etc/pacman/pacman.conf.
Forgot to add that this way the pacman.conf is decoupled of the repositories and can be replaced on updates even if a user added another repo.
This was my main motivation in adding the support for globing here.
Ok thank you, this is exactly what I wanted to know, I think it should help for the discussion. So it looks like globbing could be interesting, but user tilde expansion not so much.
Am Freitag, den 11.09.2009, 11:45 +0200 schrieb Xavier:
On Fri, Sep 11, 2009 at 11:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
Can you provide an use-case / examples justifying this ?
we use it to add repos or options by installing files into /etc/pacman/conf.d/ with a name of testing.conf for a repo called testing for example and only add
Include = /etc/pacman/conf.d/*.conf
in /etc/pacman/pacman.conf.
Forgot to add that this way the pacman.conf is decoupled of the repositories and can be replaced on updates even if a user added another repo.
This was my main motivation in adding the support for globing here.
Ok thank you, this is exactly what I wanted to know, I think it should help for the discussion.
Thanks.
So it looks like globbing could be interesting, but user tilde expansion not so much.
I agree. Will look if it can be deactivated... Marc
This patch adds the ability to use Include filenames containing wildcards. Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- --- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes") # Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,24 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_NOCHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space \n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } + globfree(&globbuf); /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
Hello List, is there any further feedback or problems that need to be solved on this one or is it ok in its last state to get accepted? Thanks, Marc Am Freitag, den 11.09.2009, 12:35 +0200 schrieb Marc - A. Dahlhaus [ Administration | Westermann GmbH ]:
This patch adds the ability to use Include filenames containing wildcards.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> ---
--- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes")
# Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,24 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_NOCHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space \n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } + globfree(&globbuf); /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
On Tue, Sep 15, 2009 at 2:11 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
Hello List,
is there any further feedback or problems that need to be solved on this one or is it ok in its last state to get accepted?
Haven't reviewed it closely yet but will let you know when I do. -Dan
On Fri, Sep 11, 2009 at 5:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- Xavier, comments here? I kind of dropped this one on the floor, but a quick review and I think it is good.
--- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes")
# Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,24 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_NOCHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space \n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } + globfree(&globbuf); /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
On Mon, Oct 12, 2009 at 4:06 AM, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, Sep 11, 2009 at 5:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- Xavier, comments here? I kind of dropped this one on the floor, but a quick review and I think it is good.
I am still not convinced that this is terribly useful. But its like 10 lines, so no big deal :) http://mailman.archlinux.org/pipermail/pacman-dev/2009-September/009361.html Like, if it's used for repos, you cannot even control their priority ? Sounds like a show-stopper to me. If not for repos, what else ?
On Sun, Nov 15, 2009 at 9:00 AM, Xavier <shiningxc@gmail.com> wrote:
On Mon, Oct 12, 2009 at 4:06 AM, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, Sep 11, 2009 at 5:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- Xavier, comments here? I kind of dropped this one on the floor, but a quick review and I think it is good.
I am still not convinced that this is terribly useful. But its like 10 lines, so no big deal :) http://mailman.archlinux.org/pipermail/pacman-dev/2009-September/009361.html
Like, if it's used for repos, you cannot even control their priority ? Sounds like a show-stopper to me. If not for repos, what else ?
Yeah, this is an interesting problem. I'm not sure glob() is even guaranteed to return results in a known (e.g. alphabetical) order. Also, looking at this, if glob returns NOSPACE, we should probably pull out the fireworks and blow up- running pacman half-configured would be no good. I'm also thinking of how many reports we are going to get of people doing recursive self-includes, but maybe I'm making a problem from nothing here. -Dan
Am Sonntag, den 15.11.2009, 20:04 -0600 schrieb Dan McGee:
On Sun, Nov 15, 2009 at 9:00 AM, Xavier <shiningxc@gmail.com> wrote:
On Mon, Oct 12, 2009 at 4:06 AM, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, Sep 11, 2009 at 5:35 AM, Marc - A. Dahlhaus [ Administration | Westermann GmbH ] <mad@wol.de> wrote:
This patch adds the ability to use Include filenames containing wildcards.
Added a headercheck for glob.h to configure.ac. Added a globfree call to clean up the struct properly. Removed tilde expanding. Fixed a no debug print on GLOB_NOMATCH condition bug.
Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- Xavier, comments here? I kind of dropped this one on the floor, but a quick review and I think it is good.
I am still not convinced that this is terribly useful. But its like 10 lines, so no big deal :) http://mailman.archlinux.org/pipermail/pacman-dev/2009-September/009361.html
Like, if it's used for repos, you cannot even control their priority ? Sounds like a show-stopper to me. If not for repos, what else ?
Yeah, this is an interesting problem. I'm not sure glob() is even guaranteed to return results in a known (e.g. alphabetical) order.
The default is to return results in sorted order ("man glob" has all the details). We use it for a /etc/pacman/repo.d directory in which we have one repository definition per file with an ##reponame.conf filename. ## represent digits from 00 to 99. We can install additional repos with packages.
Also, looking at this, if glob returns NOSPACE, we should probably pull out the fireworks and blow up- running pacman half-configured would be no good.
As this would be an out of memory condition i left the error path as it was before because i thought that there is error code handling this kind of situation in place already.
I'm also thinking of how many reports we are going to get of people doing recursive self-includes, but maybe I'm making a problem from nothing here.
This kind of error is present without globing also. A solution that might work would be to restrict the include to eg. go only 5 inclusions deep. By the way, sorry for taking so long to respond. Got a bit sidetracked by my sweet little daughter and some other things ;) Marc
This patch adds the ability to use Include filenames containing wildcards. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> --- --- pacman-3.3.0.orig/configure.ac +++ pacman-3.3.0/configure.ac @@ -150,7 +150,7 @@ fi AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes") # Checks for header files. -AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) +AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE --- pacman-3.3.0.orig/src/pacman/pacman.c +++ pacman-3.3.0/src/pacman/pacman.c @@ -38,6 +38,7 @@ #include <locale.h> /* setlocale */ #include <time.h> /* time_t */ #include <errno.h> +#include <glob.h> #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H) #include <mcheck.h> /* debug tracing (mtrace) */ #endif @@ -814,8 +815,24 @@ static int _parseconfig(const char *file } else { /* directives with settings */ if(strcmp(key, "Include") == 0) { - pm_printf(PM_LOG_DEBUG, "config: including %s\n", ptr); - _parseconfig(ptr, section, db); + int globret; + glob_t globbuf; + globret = glob(ptr, GLOB_NOCHECK, NULL, &globbuf); + switch(globret) { + case GLOB_NOSPACE: + pm_printf(PM_LOG_DEBUG, "config: include globing out of space\n"); + break; + case GLOB_ABORTED: + pm_printf(PM_LOG_DEBUG, "config: include globing read error for %s\n", ptr); + break; + default: + for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + pm_printf(PM_LOG_DEBUG, "config: including %s\n", globbuf.gl_pathv[gindex]); + _parseconfig(globbuf.gl_pathv[gindex], section, db); + } + break; + } + globfree(&globbuf); /* Ignore include failures... assume non-critical */ } else if(strcmp(section, "options") == 0) { if(strcmp(key, "NoUpgrade") == 0) {
participants (4)
-
Dan McGee
-
Marc - A. Dahlhaus
-
Marc - A. Dahlhaus [ Administration | Westermann GmbH ]
-
Xavier