#
# spec file for package at
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           at
Version:        3.1.15
Release:        1225.3
Summary:        A Job Manager
License:        GPL-2.0+
Group:          System/Daemons

Url:            ftp://ftp.debian.org/debian/pool/main/a/at
Source:         ftp://ftp.debian.org/debian/pool/main/a/at/%{name}_%{version}.orig.tar.gz
Source2:        atd.pamd
Source3:        sysconfig.atd
Source5:        atd.service

# fix for spool/cron !!!!!!! 
Patch0:         at-3.1.14.patch
Patch4:         at-3.1.14-joblist.patch
Patch5:         at-3.1.14-selinux.patch
Patch7:         at-3.1.8-eal3-manpages.patch
## no bugs anymore for patch8. Just paranoia checking
Patch8:         at-3.1.13-formatbugs.patch
Patch9:         at-3.1.13-pam.patch
Patch10:        at-3.1.13-massive_batch.patch
Patch11:        at-3.1.13-documentation-dir.patch
Patch12:        at-3.1.13-queue-nice-level.patch
# PATCH-FIX-UPSTREAM pam-session-as-root (bnc#408986, bnc#239210)
Patch14:        at-3.1.13-pam-session-as-root.patch
# PATCH-FIX-UPSTREAM clean-up opened descriptors (bnc#533454, bnc#523346)
Patch15:        at-3.1.13-leak-fix.patch
#PATCH-FIX-OPENSUSE add proper system users to the deny list
Patch16:        at-3.1.8-denylist.patch
#PATCH-FIX-UPSTREAM plan jobs with past time to tomorrow (bnc#672586)
Patch17:        at-3.1.13-tomorrow.patch
#PATCH-FIX-UPSTREAM wrong mtime handling of jobdir (bnc#680113)
Patch19:        at-3.1.8-jobdir-mtime.patch
Patch20:        at-3.1.14-parse-suse-sysconfig.patch
#PATCH-FIX-UPSTREAM fix makefile dependencies
Patch21:        at-3.1.14-makefile-deps.patch
#PATCH-FIX-OPENSUSE Set pid dir to /run not /var/run
Patch22:        at-piddir.patch
Patch23:        at-secure_getenv.patch
#PATCH-FIX-OPENSUSE backport privs from 3.1.8 (bnc#849720)
Patch24:        at-backport-old-privs.patch
#PATCH-FEATURE-UPSTREAM introduce -o <timeformat> argument for atq (bnc#879402)
Patch25:        at-atq-timeformat.patch
#PATCH-FIX-UPSTREAM sanitize environment variables (bnc#899160)
Patch26:        at-3.1.15-sane-envkeys.patch
#PATCH-FIX-OPENSUSE use posix timers to avoid the need of suspend/resume hacks.
Patch27:        at-3.1.14-usePOSIXtimers.patch
#BuildRequires:  autoconf >= 2.69
#BuildRequires:  automake
#BuildRequires:  bison
#BuildRequires:  flex
#BuildRequires:  libselinux-devel
#BuildRequires:  pam-devel
#%if 0%{?suse_version} > 1140
#BuildRequires:  libHX-devel
#BuildRequires:  pkgconfig
#BuildRequires:  pkgconfig(systemd)
#%{?systemd_requires}
#%define has_systemd 1
#%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      i486

#PreReq:         %{_sbindir}/useradd %{_sbindir}/groupadd %fillup_prereq
#PreReq:         permissions
Recommends:     smtp_daemon

%description
This program allows you to run jobs at specified times.

%prep
%setup -q
%patch0
%patch4
%patch5
%patch7
%patch8
%patch9
%patch10
%patch11
%patch12
%patch14
%patch15
%patch16
%patch17 -p1
%patch19
%patch20
%patch21 -p1
%patch22
%patch23 -p1
%patch24 -p1
%patch25
%patch26 -p1
%patch27 -p1
%build
rm -fv y.tab.c y.tab.h lex.yy.c lex.yy.o y.tab.o
autoreconf -fiv

export CFLAGS="%{?optflags} -fPIE"
export LDFLAGS="-pie"
export SENDMAIL=%{_sbindir}/sendmail

%configure \
  --with-pam \
  --with-daemon_username=daemon \
  --with-daemon_groupname=daemon

%{__make} %{?_smp_mflags}

%install
%{__install} -d %{buildroot}{%{_sysconfdir}/pam.d,%{_bindir},%{_sbindir},%{_mandir}/man{1,5,8},%{_localstatedir}/adm/fillup-templates}

export CFLAGS="%{?optflags}"
export SENDMAIL=%{_sbindir}/sendmail

%{__make} install IROOT=%{buildroot}

# Don't install docs here in this way
mkdir docs
mv %{buildroot}/%{_prefix}/doc/at/* docs/

%{__install} -D -m 0644 %{S:5} %{buildroot}%{_unitdir}/atd.service
%{__ln_s} -f %{_sbindir}/service %{buildroot}%{_sbindir}/rcatd

%{__install} -m644 %SOURCE2 %{buildroot}%{_sysconfdir}/pam.d/atd
%{__install} -m644 %SOURCE3 %{buildroot}%{_localstatedir}/adm/fillup-templates

%pre
%{_sbindir}/groupadd -g 25 -o -r at 2> /dev/null || :
%{_sbindir}/useradd -r -o -g at -u 25 -s /bin/bash -c "Batch jobs daemon" -d /var/spool/atjobs at 2> /dev/null || :
%service_add_pre atd.service

%preun
%service_del_preun atd.service

%post
%fillup_only -n atd
%set_permissions /usr/bin/at
%service_add_post atd.service

%verifyscript
%verify_permissions -e /usr/bin/at

%postun
%service_del_postun atd.service

%files
%defattr(-,root,root)
%doc Problems Copyright COPYING README ChangeLog timespec
%config(noreplace) %{_sysconfdir}/at.deny
%{_sbindir}/rcatd
%config %attr(644,root,root) %{_sysconfdir}/pam.d/atd
%verify(not mode) %attr(4750,root,trusted) %{_bindir}/at
%{_bindir}/atq
%{_bindir}/atrm
%{_bindir}/batch
%{_mandir}/man?/*
%{_sbindir}/atd
%{_sbindir}/atrun
%attr(700,at,at) %dir /var/spool/cron/atspool
%attr(1770,at,at) %dir /var/spool/cron/atjobs
%attr(600,at,at) /var/spool/cron/atjobs/.SEQ
%{_localstatedir}/adm/fillup-templates/sysconfig.atd
#%{_unitdir}/atd.service

%changelog
* Mon Oct  6 2014 lchiquitto@suse.com
- Replace at-sane-envkeys.diff by at-3.1.15-sane-envkeys.patch,
  a simpler fix from upstream [bsc#899160]
* Fri Oct  3 2014 crrodriguez@opensuse.org
- at-3.1.14-usePOSIXtimers.patch (from Fedora)
  Use Posix timers, this
  avoid the need of horrible suspend/resume hacks like at.sleep
  with pm-utils/systemd
* Tue Sep 30 2014 jengelh@inai.de
- Add at-sane-envkeys.diff to skip exporting variables with
  awkward keys [bsc#899160]
* Wed Sep 24 2014 pgajdos@suse.com
- updated to 3.1.15:
  * pam.conf: require pam_loginuid.so
  * atd.service.in: Add Documentation field.
  * atd.service.in: Set IgnoreSIGPIPE=false
* Thu Jul 31 2014 alarrosa@suse.com
- Remove a relative path that is not needed in the service symlink
* Mon Jul 28 2014 crrodriguez@opensuse.org
- Remove extra remains of sysvinit compat.
- Restore needed call to fillup_only that went lost in the
  sysvinit change.
* Fri Jul 25 2014 pgajdos@suse.com
- introduced -o <timeformat> switch for atq [bnc#879402]
  * added at-atq-timeformat.patch
* Mon Jun 16 2014 vdziewiecki@suse.com
-Removed init script
-fix bnc#880364 - at pam file is not calling pam_loginuid
* Mon Mar  3 2014 aj@ajaissle.de
- New upstream release 3.1.14
  + Add systemd service file. (deb#639634)
  + Initialize jobno before using it.
  + No longer try to compile and run a trivial C program. (deb#632301)
  + Add -M option to usage message.
  + Use LDFLAGS when linking programs.
- Rebased the following patches:
  * at-3.1.13.patch as at-3.1.14.patch
  * at-3.1.13-joblist.patch as at-3.1.14-joblist.patch
  * at-3.1.13-selinux.patch as at-3.1.14-selinux.patch
  * at-parse-suse-sysconfig.patch as at-3.1.14-parse-suse-sysconfig.patch
  * at-makefile-deps.patch as at-3.1.14-makefile-deps.patch
- Dropped at-3.1.13-pie.patch (obsolete, now using LDFLAGS)
- Changed systemd service file [Unit] -> "Description" to match upstream
- Spec: cleanup + use some macros
* Thu Jan 23 2014 aj@ajaissle.de
- Fixed leaking the exit code of systemctl in atd.sh. A change
  to at.sleep prevents leaking systemctl exit code as well as
  simplifies the script.
* Tue Nov 12 2013 mvyskocil@suse.com
- use old privs model (fixes bnc#849720)
  * at-backport-old-privs.patch
- do not install sysvinit script and service file together
- add sticky bit to atjobs
* Tue Oct 22 2013 meissner@suse.com
- adding service hook was in %%verifyscript section not in %%post
* Sun Oct  6 2013 crrodriguez@opensuse.org
- at-secure_getenv.patch at must use secure_getenv.
* Mon Jul 15 2013 werner@suse.de
- No http://0pointer.de/public/systemd-units/atd.service anymore
* Sat Jul 13 2013 crrodriguez@opensuse.org
- systemd: start as non-forking service
- systemd: start after systemd-user-sessions.service
* Sat Jul 13 2013 crrodriguez@opensuse.org
- Use /run not /var/run to store the pid file
* Thu Jun 20 2013 crrodriguez@opensuse.org
- at.sleep move away from pm-utils to systemd-sleep
* Tue Jun 18 2013 schwab@suse.de
- at-makefile-deps.patch: fix makefile dependencies
* Tue Jun 11 2013 lang@b1-systems.de
- updated to upstream 3.1.13
- ported patches to new source code in session with Stefan Seyfried
- removed unnecessary patches
* Sun Apr 14 2013 crrodriguez@opensuse.org
- Ordering after syslog.target is no longer recommended.
* Wed Feb  6 2013 opensuse@cboltz.de
- fix author information in at-parse-suse-sysconfig.patch (bnc#780259#c25)
* Sun Jan  6 2013 jengelh@inai.de
- Use simpler HXmap_get in at-parse-suse-sysconfig.patch
  (bnc#780259)
* Wed Nov 28 2012 crrodriguez@opensuse.org
- When sysconfig variables are empty, do not set stuff to zero
  just use the defaults.
* Wed Nov 28 2012 crrodriguez@opensuse.org
- Fix systemd unit and sysconfig parsing the right way.
* Mon Nov 26 2012 opensuse@cboltz.de
- use /etc/sysconfig/atd variables in atd.service (bnc#780259#c4)
* Thu Sep 13 2012 opensuse@cboltz.de
- fix atd.service (bnc#780259)
* Tue Dec 20 2011 coolo@suse.com
- add autoconf as buildrequire to avoid implicit dependency
* Tue Dec 20 2011 coolo@suse.com
- remove call to suse_update_config (very old work around)
* Mon Dec  5 2011 crrodriguez@opensuse.org
- Fix rpmlint warnings
* Mon Dec  5 2011 crrodriguez@opensuse.org
- Support systemd.
* Sat Sep 17 2011 jengelh@medozas.de
- Remove redundant tags/sections from specfile
- Use %%_smp_mflags for parallel build
* Fri May 13 2011 vcizek@novell.com
- added missing license to distribution (bnc#693355)
* Tue Apr 19 2011 vcizek@novell.com
- wrong jobdir mtime handling fixed (bnc#680113)
  thanks to Ingo Schwarze
* Tue Apr  5 2011 vcizek@novell.com
- fixed atd-atrm race condition (bnc#679857)
* Tue Mar  1 2011 vcizek@novell.com
- fixed bug introduced with at-3.1.8-tomorrow.patch (bnc#672586)
* Mon Feb  7 2011 jslaby@suse.de
- source pm-utils functions in suspend/resume script to avoid
  errors
* Tue Feb  1 2011 vcizek@novell.com
- at now shifts jobs with passed time without a date to tomorrow
  (bnc#668485)
* Wed Nov 10 2010 coolo@novell.com
- own parent directories
* Tue Sep 28 2010 cristian.rodriguez@opensuse.org
- /etc/at.deny has wrong account name [bnc#632250]
* Tue Jul 20 2010 cristian.rodriguez@opensuse.org
- wake up atd after suspend [bnc#592349]
* Sat Jul 17 2010 cristian.rodriguez@opensuse.org
- improve spec file
- Should Recommend smtp_daemon
* Wed Nov 18 2009 mseben@novell.com
- added pam conversion function (reworked pam.patch) fate#306386
* Tue Nov  3 2009 coolo@novell.com
- updated patches to apply with fuzz=0
* Thu Aug 27 2009 mseben@novell.com
- closedir.patch renamed to leak-fix.patch and added others fixs
  of resource leaks (bnc#533454)
* Thu Aug 13 2009 mseben@novell.com
- added closedir.patch fix missing call of closedir() (bnc#523346)
* Thu May 14 2009 puzel@suse.cz
- added at-3.1.8-pam-session-as-root.patch (bnc#329210, bnc#408986)
* Mon Mar  2 2009 sebo@suse.de
- added cleanup_perm.patch to fix permissions for unlink (bnc#478733)
* Thu Feb 12 2009 mseben@suse.cz
- fixed nice level of queues : queue-nice-level.patch [bnc#225463]
* Thu Jan  8 2009 prusnak@suse.cz
- corrected selinux.patch [bnc#463521]
* Wed Oct  8 2008 bwalle@suse.de
- Fix documentation directory in at(1).
* Mon Sep  1 2008 puzel@suse.cz
- enabled SELinux support [Fate#303662]
* Tue Apr  8 2008 mrueckert@suse.de
- add at-3.1.8_massive_batch.patch: (bnc#347126)
  properly handle sighup when multiple jobs are submitted at the
  same time
* Fri May 11 2007 mrueckert@suse.de
- remove postfix from the build requires. (#225469)
* Thu Mar 29 2007 meissner@suse.de
- buildrequires flex,bison
* Mon Mar 19 2007 mrueckert@suse.de
- readd at-3.1.8-pam.diff: (#222563)
  The breaking part of the setreuid(daemon_uid,daemon_uid) in
  perm.c. uid 25 can not write audit messages. As upstream removed
  the pam code in perm.c aswell, we do the same here.
* Mon Dec 18 2006 ro@suse.de
- added sysconfig variables ATD_BATCH_INTERVAL
  and ATD_LOADAVG (fate#301318)
* Tue Nov 28 2006 mrueckert@suse.de
- remove at-3.1.8-pam.diff it just breaks at.
* Tue Nov 21 2006 ro@suse.de
- added PRIV_START/END calls around pam_start sections (#222412)
* Fri Sep  1 2006 kukuk@suse.de
- Add pam_loginuid.so to atd.pamd
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Thu Jan 12 2006 schwab@suse.de
- Don't strip binaries.
* Mon Dec  5 2005 kukuk@suse.de
- Disable SELinux
* Mon Aug 29 2005 kukuk@suse.de
- Make pam config file non-executeable
* Thu Aug 25 2005 kukuk@suse.de
- Remove pam_loginuid.so  [may fix #112802]
* Mon Aug 15 2005 kukuk@suse.de
- Update to at-3.1.8-11 tarball (includes old patches)
- Add PAM support
* Thu Jun  2 2005 kukuk@suse.de
- Compile with -fpie/-pie
- Update SELinux patch
* Sat Feb  5 2005 meissner@suse.de
- mark up for format string using functions.
- fixed one error output
* Tue May 25 2004 ro@suse.de
- added "-t" docu to manpage
* Thu Mar 25 2004 mmj@suse.de
- Add postfix to # neededforbuild
* Tue Mar 23 2004 thomas@suse.de
- Added patch for EAL3 man-pages
* Tue Mar 23 2004 thomas@suse.de
- Added patch for LAuS
* Wed Jan 28 2004 kukuk@suse.de
- Add patch for SELinux
* Mon Oct 27 2003 ro@suse.de
- package /usr/bin/at as 4750,root,trusted as in permissions.secure
- add verify (not mode) for /usr/bin/at
- add run_permissions macro to postinstall
* Sun Oct 19 2003 ro@suse.de
- don't build as root
* Tue Oct  7 2003 ro@suse.de
- support "at -l -q queue" and "-t timespec" (#31957)
  (ported from FreeBSD)
* Fri Aug 29 2003 kukuk@suse.de
- Create at as system account [Bug #29611]
* Fri Aug 15 2003 ro@suse.de
- make "at -r" behave like "at -d" (#28753)
- added restart_on_update/stop_on_removal macros
* Fri Jul 18 2003 kukuk@suse.de
- Fix spec file/Makefile to be able to build as normal user
* Wed Jun 18 2003 ro@suse.de
- added "X-UnitedLinux-Default-Enabled: no" to init-script
* Wed Jun 18 2003 ro@suse.de
- don't activate by default
* Mon May 19 2003 ro@suse.de
- fix filelist
* Mon May 12 2003 ro@suse.de
- use defattr
* Tue Mar 11 2003 ro@suse.de
- fix postinstall for updates (appeared in #24653)
* Thu Nov  7 2002 tcrhak@suse.cz
- fixed for bison 1.75: end rules with semicolon
* Fri Aug 23 2002 bk@suse.de
- mark /etc/at.deny as noreplace
* Mon Aug 19 2002 kukuk@suse.de
- Use $time instead of xntp in init script.
* Thu Aug  1 2002 ro@suse.de
- added prereqs
* Mon Jul  1 2002 ro@suse.de
- add ntp to Required-Start in init-script (#15833)
* Mon May 27 2002 ro@suse.de
- set SIGCHLD handler back to default when starting job
* Thu May 23 2002 ro@suse.de
- create user in install section
* Wed May 22 2002 kukuk@suse.de
- Create at user/group in preinstall script
* Tue Apr  2 2002 ro@suse.de
- don't try to copy config.guess and config.sub
  (already done by suse_update_config)
* Wed Jan 16 2002 ro@suse.de
- integrated two patches:
  at-3.1.8-heapcorruption.dif and at-3.1.8-o_excl.dif
  against heap corruption in time parser for commandline and for
  safer opening of a file (O_EXCL).
- removed all generated files from patch and copy config.{sub,guess}
  from current automake
* Wed Jan  9 2002 kukuk@suse.de
- Fix path to timespec in at.1 manual page [Bug #12784]
* Tue Jan  8 2002 egmont@suselinux.hu
- removed colons from init script messages
* Wed Jan  2 2002 kukuk@suse.de
- Remove warning about cron and at (never worked before and user
  cannot see it)
- Rename init script from at to atd
- Don't source rc.config in init script (not needed any longer)
- Remove $route from init script dependencies (does not exist)
  [Bug #12689]
- Use BuildRoot
* Fri Dec 14 2001 ro@suse.de
- removed START_ATD
* Mon Aug  6 2001 ro@suse.de
- updated rc script
* Fri Jun 15 2001 schwab@suse.de
- Add %%suse_update_config.
* Tue Nov 28 2000 ro@suse.de
- startscript to etc/init.d
* Mon Sep 25 2000 ro@suse.de
- sorted
* Wed Feb 16 2000 dipa@suse.de
- apply debian patch at_3.1.8-8.diff full section of: at.c, at.1.in,
  at.deny, at_allow.5, atd.8.in, at.8.in, batch config.guess,
  config.sub, daemon.c, lex.yy.c, panic.c, parsetime.y, y.tab.c
  (fix for bug #1766)
* Fri Feb  4 2000 ro@suse.de
- fix missing getlock preload
* Fri Feb  4 2000 ro@suse.de
- applied security fixes from thomas
* Mon Jan 17 2000 ro@suse.de
- man -> usr/share/man
* Mon Sep 13 1999 bs@suse.de
- ran old prepare_spec on spec file to switch to new prepare_spec.
* Tue Dec  8 1998 ro@suse.de
- added reload to script (does a restart)
* Mon Dec  7 1998 ro@suse.de
- added symlink /sbin/rcat -> init.d/at
* Mon Dec  7 1998 ro@suse.de
- updated init-script
* Fri Feb 27 1998 ro@suse.de
- installed timespec in docdir / fixed path in manpage
* Mon Oct 27 1997 ro@suse.de
- update to version 3.1.8
  ready for autobuild
* Sun Jun 22 1997 florian@suse.de
- update to version 3.1.7
* Sun Jun  1 1997 bs@suse.de
- moved fillup stuff to var/adm/fillup-templates
* Thu Jan  2 1997 bs@suse.de
  boot script beautified.
* Thu Jan  2 1997 bs@suse.de
  recompiled and added README
* Thu Jan  2 1997 bs@suse.de
- /var/spool/atspool/atspool fixed.
* Thu Jan  2 1997 bs@suse.de
- new version 3.0
- fillup etc/rc.config and sbin/init.d/at added.
* Thu Jan  2 1997 bs@suse.de
  switched to version pre-3.0-960812.
  New: atd (daemon)
  fillup etc/rc.config and sbin/init.d-stuff added.
* Thu Jan  2 1997 florian@suse.de
  allow login names to be up to 16 characters long