From 1db49b09b574152558df4b5acfb6b3ee59027970a5214914f258ff3c3552b11a Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Thu, 29 Nov 2012 10:10:11 +0000 Subject: [PATCH] Accepting request 143496 from home:elvigia:branches:Base:System - When sysconfig variables are empty, do not set stuff to zero just use the defaults. - Fix systemd unit and sysconfig parsing the right way. OBS-URL: https://build.opensuse.org/request/show/143496 OBS-URL: https://build.opensuse.org/package/show/Base:System/at?expand=0&rev=50 --- at-parse-suse-sysconfig.patch | 160 ++++++++++++++++++++++++++++++++++ at.changes | 11 +++ at.spec | 8 +- atd.service | 2 +- 4 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 at-parse-suse-sysconfig.patch diff --git a/at-parse-suse-sysconfig.patch b/at-parse-suse-sysconfig.patch new file mode 100644 index 0000000..fc652c1 --- /dev/null +++ b/at-parse-suse-sysconfig.patch @@ -0,0 +1,160 @@ +--- atd.c.orig ++++ atd.c +@@ -104,8 +104,15 @@ static pam_handle_t *pamh = NULL; + } + #endif + ++#include ++#include ++#include ++ ++ + /* Local headers */ + ++#define streq(a, b) (strcmp((a), (b)) == 0) ++ + #include "privs.h" + #include "daemon.h" + +@@ -996,6 +1003,30 @@ main(int argc, char *argv[]) + } + } + ++ struct HXmap *sysconfigmap; ++ const struct HXmap_node *node; ++ struct HXmap_trav *trav; ++ ++ sysconfigmap = HX_shconfig_map("/etc/sysconfig/atd"); ++ ++ if(sysconfigmap != NULL) ++ { ++ trav = HXmap_travinit(sysconfigmap, HXMAP_NOFLAGS); ++ while ((node = HXmap_traverse(trav)) != NULL) { ++ if(streq(node->skey, "ATD_BATCH_INTERVAL") && strlen(node->sdata) != 0) { ++ batch_interval = atoi(node->sdata); ++ syslog(LOG_INFO, "sysconfig requested batch_interval to be set to %d\n", batch_interval); ++ } ++ if(streq(node->skey, "ATD_LOADAVG") && strlen(node->sdata) != 0) { ++ load_avg = atof(node->sdata); ++ syslog(LOG_INFO, "sysconfig requested load_avg to be set to %lf\n", load_avg); ++ } ++ } ++ ++ HXmap_travfree(trav); ++ HXmap_free(sysconfigmap); ++ } ++ + namep = argv[0]; + if (chdir(ATJOB_DIR) != 0) + perr("Cannot change to " ATJOB_DIR); +--- configure.in.orig ++++ configure.in +@@ -1,9 +1,10 @@ + dnl Process this file with autoconf to produce a configure script. + +-AC_INIT(at.c) ++AC_INIT ++AC_CONFIG_SRCDIR([at.c]) + AC_PREFIX_DEFAULT(/usr) + AC_CONFIG_HEADER(config.h) +-AC_PREREQ(2.7) ++AC_PREREQ([2.69]) + + + VERSION="3.1.8" +@@ -39,25 +40,22 @@ case "$host" in + ;; + esac + AC_MSG_CHECKING(Trying to compile a trivial ANSI C program) +-AC_TRY_RUN([ main(int ac, char **av) { return 0; } ], +- AC_MSG_RESULT(yes), +- AC_MSG_RESULT(no) +- AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.), +- AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.)) ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ main(int ac, char **av) { return 0; } ]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) ++ AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.)],[AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.)]) + + AC_MSG_CHECKING(__attribute__((noreturn))) +-AC_TRY_COMPILE([], [void __attribute__((noreturn)) panic(void);], +- AC_MSG_RESULT(yes) +- AC_DEFINE(HAVE_ATTRIBUTE_NORETURN), +- AC_MSG_RESULT(no) +-) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void __attribute__((noreturn)) panic(void);]])],[AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_ATTRIBUTE_NORETURN)],[AC_MSG_RESULT(no) ++]) + dnl Checks for libraries. + + AC_CHECK_LIB(fl,yywrap, + [], +- AC_DEFINE(NEED_YYWRAP) ++ AC_DEFINE([NEED_YYWRAP], 1, [need yywrap]) + ) + ++PKG_CHECK_MODULES([HX], [libHX]) ++ + dnl Checks for header files. + AC_HEADER_DIRENT + AC_HEADER_STDC +@@ -67,7 +65,18 @@ AC_CHECK_HEADERS(stdarg.h) + + dnl Checks for typedefs, structures, and compiler characteristics. + AC_C_CONST +-AC_TYPE_SIGNAL ++AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. ++Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl ++AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( ++[AC_LANG_PROGRAM([#include ++#include ++], ++ [return *(signal (0, 0)) (0) == 1;])], ++ [ac_cv_type_signal=int], ++ [ac_cv_type_signal=void])]) ++AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers ++ (`int' or `void').]) ++ + AC_TYPE_UID_T + AC_TYPE_MODE_T + AC_TYPE_OFF_T +@@ -317,7 +326,7 @@ AC_SUBST(DAEMON_GROUPNAME) + + AC_ARG_WITH(selinux, + [ --with-selinux Define to run with selinux], +-AC_DEFINE(WITH_SELINUX), ++AC_DEFINE([WITH_SELINUX] , [1], [enable selinux]), + ) + AC_CHECK_LIB(selinux, is_selinux_enabled, SELINUXLIB=-lselinux) + AC_SUBST(SELINUXLIB) +@@ -325,9 +334,10 @@ AC_SUBST(WITH_SELINUX) + + AC_ARG_WITH(pam, + [ --with-pam Define to enable pam support ], +-AC_DEFINE(WITH_PAM), ++AC_DEFINE([WITH_PAM], [1], [with pam]), + ) + AC_CHECK_LIB(pam, pam_start, PAMLIB='-lpam -lpam_misc') + AC_SUBST(PAMLIB) + +-AC_OUTPUT(Makefile atrun atd.8 atrun.8 at.1 batch) ++AC_CONFIG_FILES([Makefile atrun atd.8 atrun.8 at.1 batch]) ++AC_OUTPUT +--- Makefile.in.orig ++++ Makefile.in +@@ -31,7 +31,7 @@ SELINUXLIB = @SELINUXLIB@ + PAMLIB = @PAMLIB@ + + CC = @CC@ +-CFLAGS = @CFLAGS@ ++CFLAGS = @CFLAGS@ @HX_CFLAGS@ + LDFLAGS = @LDFLAGS@ + LFILE = $(ATJOB_DIR)/.SEQ + DEFS = @DEFS@ -DVERSION=\"$(VERSION)\" \ +@@ -39,7 +39,7 @@ DEFS = @DEFS@ -DVERSION=\"$(VERSION)\" + -DDAEMON_USERNAME=\"$(DAEMON_USERNAME)\" \ + -DDAEMON_GROUPNAME=\"$(DAEMON_GROUPNAME)\" \ + -DLFILE=\"$(LFILE)\" -Wall +-LIBS = @LIBS@ ++LIBS = @LIBS@ @HX_LIBS@ + LIBOBJS = @LIBOBJS@ + INSTALL = @INSTALL@ + diff --git a/at.changes b/at.changes index 33fea1e..2697a3d 100644 --- a/at.changes +++ b/at.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Wed Nov 28 21:46:58 UTC 2012 - crrodriguez@opensuse.org + +- When sysconfig variables are empty, do not set stuff to zero + just use the defaults. + +------------------------------------------------------------------- +Wed Nov 28 20:51:49 UTC 2012 - crrodriguez@opensuse.org + +- Fix systemd unit and sysconfig parsing the right way. + ------------------------------------------------------------------- Mon Nov 26 18:11:09 UTC 2012 - opensuse@cboltz.de diff --git a/at.spec b/at.spec index 305ce11..7d70808 100644 --- a/at.spec +++ b/at.spec @@ -18,6 +18,7 @@ Name: at BuildRequires: autoconf +BuildRequires: automake BuildRequires: bison BuildRequires: flex BuildRequires: libselinux-devel @@ -61,11 +62,14 @@ Patch17: %{name}-%{version}-tomorrow.patch Patch18: %{name}-%{version}-atrm-race.patch #PATCH-FIX-UPSTREAM wrong mtime handling of jobdir (bnc#680113) Patch19: %{name}-%{version}-jobdir-mtime.patch +Patch20: at-parse-suse-sysconfig.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build PreReq: %{_sbindir}/useradd %{_sbindir}/groupadd %fillup_prereq %insserv_prereq PreReq: permissions Recommends: smtp_daemon %if 0%{?suse_version} > 1140 +BuildRequires: libHX-devel +BuildRequires: pkgconfig BuildRequires: systemd %{?systemd_requires} %define has_systemd 1 @@ -96,10 +100,10 @@ This program allows you to run jobs at specified times. %patch17 -p1 %patch18 %patch19 - +%patch20 %build rm -fv y.tab.c y.tab.h lex.yy.c lex.yy.o y.tab.o -autoconf +autoreconf -fiv export SENDMAIL=%{_sbindir}/sendmail %configure \ --with-pam \ diff --git a/atd.service b/atd.service index c8a2cf1..70aa15b 100644 --- a/atd.service +++ b/atd.service @@ -3,7 +3,7 @@ Description=Execution Queue Daemon After=syslog.target [Service] -ExecStart=/bin/bash -c '[ -e /etc/sysconfig/atd ] && . /etc/sysconfig/atd; exec /usr/sbin/atd $${ATD_BATCH_INTERVAL:+-b $$ATD_BATCH_INTERVAL} $${ATD_LOADAVG:+-l $$ATD_LOADAVG}' +ExecStart=/usr/sbin/atd Type=forking [Install]