[autofs] * Fri Dec 9 2011 Ian Kent <ikent at redhat.com> - 1:5.0.6-6 - remove empty command line arguments (pass
Ian Kent
iankent at fedoraproject.org
Fri Dec 9 07:10:53 UTC 2011
commit e232a5634433a54d884b3dd5d19de3e23f698c25
Author: Ian Kent <raven at themaw.net>
Date: Fri Dec 9 15:10:24 2011 +0800
* Fri Dec 9 2011 Ian Kent <ikent at redhat.com> - 1:5.0.6-6
- remove empty command line arguments (passed by systemd).
...5.0.6-remove-empty-command-line-arguments.patch | 117 ++++++++++++++++++++
autofs.spec | 7 +-
2 files changed, 123 insertions(+), 1 deletions(-)
---
diff --git a/autofs-5.0.6-remove-empty-command-line-arguments.patch b/autofs-5.0.6-remove-empty-command-line-arguments.patch
new file mode 100644
index 0000000..6c5c226
--- /dev/null
+++ b/autofs-5.0.6-remove-empty-command-line-arguments.patch
@@ -0,0 +1,117 @@
+autofs-5.0.6 - remove empty command line arguments
+
+From: Ian Kent <raven at themaw.net>
+
+When invoking the automount daemon from a systemd unit file a macro
+that evaluates to the empty string is passed as an empty argument
+unlike the shell environment within which unquoted arguments are
+seen as white space and are not passed at all.
+
+These empty arguments confuse getopt(3) and cause the program
+parameters to be misread so we need to remove them before calling
+getopt(3).
+---
+
+ CHANGELOG | 1 +
+ daemon/automount.c | 39 +++++++++++++++++++++++++++++++++++----
+ 2 files changed, 36 insertions(+), 4 deletions(-)
+
+
+diff --git a/CHANGELOG b/CHANGELOG
+index d951b5a..8dec17f 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -19,6 +19,7 @@
+ - fix ipv6 configure check.
+ - add piddir to configure.
+ - add systemd unit support.
++- remove empty command line arguments (passed by systemd).
+
+ 28/06/2011 autofs-5.0.6
+ -----------------------
+diff --git a/daemon/automount.c b/daemon/automount.c
+index 6bb5aa8..c0b4b85 100644
+--- a/daemon/automount.c
++++ b/daemon/automount.c
+@@ -1865,6 +1865,34 @@ static int convert_log_priority(char *priority_name)
+ return -1;
+ }
+
++static void remove_empty_args(char **argv, int *argc)
++{
++ int next_to_last = *argc - 1;
++ int i, j;
++
++ for (i = j = 1; i < *argc; i++) {
++ if (*argv[i]) {
++ j++;
++ continue;
++ }
++
++ while (i < *argc && argv[i] && !*argv[i]) i++;
++
++ if (i == *argc)
++ break;
++
++ if (i == next_to_last) {
++ if (*argv[i])
++ argv[j++] = argv[i];
++ break;
++ } else {
++ argv[j++] = argv[i];
++ argv[i--] = "";
++ }
++ }
++ *argc = j;
++}
++
+ int main(int argc, char *argv[])
+ {
+ int res, opt, status;
+@@ -1874,6 +1902,7 @@ int main(int argc, char *argv[])
+ time_t timeout;
+ time_t age = time(NULL);
+ struct rlimit rlim;
++ const char *options = "+hp:t:vmdD:fVrO:l:n:CF";
+ static const struct option long_options[] = {
+ {"help", 0, 0, 'h'},
+ {"pid-file", 1, 0, 'p'},
+@@ -1918,8 +1947,10 @@ int main(int argc, char *argv[])
+ dumpmaps = 0;
+ daemon_check = 1;
+
++ remove_empty_args(argv, &argc);
++
+ opterr = 0;
+- while ((opt = getopt_long(argc, argv, "+hp:t:vmdD:fVrO:l:n:CF", long_options, NULL)) != EOF) {
++ while ((opt = getopt_long(argc, argv, options, long_options, NULL)) != EOF) {
+ switch (opt) {
+ case 'h':
+ usage();
+@@ -2066,7 +2097,7 @@ int main(int argc, char *argv[])
+ res = setrlimit(RLIMIT_NOFILE, &rlim);
+ if (res)
+ printf("%s: can't increase open file limit - continuing",
+- argv[0]);
++ program);
+
+ #if ENABLE_CORES
+ rlim.rlim_cur = RLIM_INFINITY;
+@@ -2074,7 +2105,7 @@ int main(int argc, char *argv[])
+ res = setrlimit(RLIMIT_CORE, &rlim);
+ if (res)
+ printf("%s: can't increase core file limit - continuing",
+- argv[0]);
++ program);
+ #endif
+
+ if (argc == 0)
+@@ -2097,7 +2128,7 @@ int main(int argc, char *argv[])
+ nc = cache_init_null_cache(master_list);
+ if (!nc) {
+ printf("%s: failed to init null map cache for %s",
+- master_list->name, argv[0]);
++ program, master_list->name);
+ exit(1);
+ }
+ master_list->nc = nc;
diff --git a/autofs.spec b/autofs.spec
index 8424791..f6d00f9 100644
--- a/autofs.spec
+++ b/autofs.spec
@@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.0.6
-Release: 5%{?dist}
+Release: 6%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@@ -33,6 +33,7 @@ Patch17: autofs-5.0.6-fix-ipv6-configure-check.patch
Patch18: autofs-5.0.6-add-piddir-to-configure.patch
Patch19: autofs-5.0.6-add-systemd-unit-support.patch
Patch20: autofs-5.0.6-fix-MNT_DETACH-define.patch
+Patch21: autofs-5.0.6-remove-empty-command-line-arguments.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if %{with_systemd}
BuildRequires: systemd-units
@@ -108,6 +109,7 @@ echo %{version}-%{release} > .version
%patch18 -p1
%patch19 -p1
%patch20 -p1
+%patch21 -p1
%build
#CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -191,6 +193,9 @@ fi
%dir /etc/auto.master.d
%changelog
+* Fri Dec 9 2011 Ian Kent <ikent at redhat.com> - 1:5.0.6-6
+- remove empty command line arguments (passed by systemd).
+
* Mon Dec 5 2011 Ian Kent <ikent at redhat.com> - 1:5.0.6-5
- fix ipv6 name lookup check.
- fix ipv6 rpc calls.
More information about the scm-commits
mailing list