create core package

This commit is contained in:
aydemir
2015-02-24 11:18:35 +02:00
parent 0e4b743b82
commit 70b25d0f95
1098 changed files with 169545 additions and 0 deletions
@@ -0,0 +1,29 @@
diff -uPr do_command.c do_command.c
--- do_command.c 2006-05-25 16:44:26.000000000 +0400
+++ do_command.c 2006-05-25 16:42:25.000000000 +0400
@@ -240,12 +240,23 @@
}
}
#else
- setgid(e->pwd->pw_gid);
+
initgroups(usernm, e->pwd->pw_gid);
#if (defined(BSD)) && (BSD >= 199103)
setlogin(usernm);
#endif /* BSD */
- setuid(e->pwd->pw_uid); /* we aren't root after this... */
+ // setuid(e->pwd->pw_uid); /* we aren't root after this... */
+
+ if ( setgid(e->pwd->pw_gid) == -1 ) {
+ fprintf(stderr,"can't set gid for %s\n", e->pwd->pw_name);
+ _exit(1);
+ }
+
+ if ( setuid(e->pwd->pw_uid) == -1 ) {
+ fprintf(stderr,"can't set uid for %s\n", e->pwd->pw_name);
+ _exit(1);
+ }
+
#endif /* LOGIN_CAP */
chdir(env_get("HOME", e->envp));
@@ -0,0 +1,11 @@
--- database.c.orig 2007-04-08 21:06:16.913019387 +0200
+++ database.c 2007-04-08 21:06:29.489736093 +0200
@@ -251,7 +251,7 @@
log_it(fname, getpid(), "WRONG FILE OWNER", tabname);
goto next_crontab;
}
- if (statbuf->st_nlink != 1) {
+ if (statbuf->st_nlink != 1 && pw != NULL) {
log_it(fname, getpid(), "BAD LINK COUNT", tabname);
goto next_crontab;
}
+7
View File
@@ -0,0 +1,7 @@
#%PAM-1.0
account required pam_unix.so
auth required pam_unix.so
session required pam_limits.so
+14
View File
@@ -0,0 +1,14 @@
# for vixie cron
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
*/15 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons
0 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
0 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
15 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
30 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
@@ -0,0 +1,35 @@
--- crontab.5.orig 2004-02-19 20:40:04.954132624 +0000
+++ crontab.5 2004-02-19 20:45:27.033169168 +0000
@@ -153,6 +153,32 @@
``30 4 1,15 * 5''
would cause a command to be run at 4:30 am on the 1st and 15th of each
month, plus every Friday.
+.PP
+Instead of the first five fields, one of eight special strings may
+appear:
+.IP
+.ta 1.5i
+string meaning
+.br
+------ -------
+.br
+@reboot Run once, at startup.
+.br
+@yearly Run once a year, "0 0 1 1 *".
+.br
+@annually (same as @yearly)
+.br
+@monthly Run once a month, "0 0 1 * *".
+.br
+@weekly Run once a week, "0 0 * * 0".
+.br
+@daily Run once a day, "0 0 * * *".
+.br
+@midnight (same as @daily)
+.br
+@hourly Run once an hour, "0 * * * *".
+.br
+.fi
.SH EXAMPLE CRON FILE
.nf
@@ -0,0 +1,87 @@
#!/bin/bash
#
# Mostly copied from SuSE and Gentoo
#
# this script looks into /etc/cron.[hourly|daily|weekly|monthly]
# for scripts to be executed. The info about last run is stored in
# /var/spool/cron/lastrun
LOCKDIR=/var/spool/cron/lastrun
LOCKFILE=${LOCKDIR}/lock
mkdir -p ${LOCKDIR}
# Make sure we're not running multiple instances at once.
# Try twice to lock, otherwise give up.
for ((i = 0; i < 2; i = i + 1)); do
ln -sn $$ ${LOCKFILE} 2>/dev/null && break
# lock failed, check for a running process.
# handle both old- and new-style locking.
cronpid=$(readlink ${LOCKFILE} 2>/dev/null) ||
cronpid=$(cat ${LOCKFILE} 2>/dev/null) ||
continue # lockfile disappeared? try again
# better than kill -0 because we can verify that it's really
# another run-crons process
if [[ $(</proc/${cronpid}/cmdline) == $(</proc/$$/cmdline) ]] 2>/dev/null; then
# whoa, another process is really running
exit 0
else
rm -f ${LOCKFILE}
fi
done
# Check to make sure locking was successful
if [[ ! -L ${LOCKFILE} ]]; then
echo "Can't create or read existing ${LOCKFILE}, giving up"
exit 1
fi
# Set a trap to remove the lockfile when we're finished
trap "rm -f ${LOCKFILE}" 0 1 2 3 15
for BASE in hourly daily weekly monthly
do
CRONDIR=/etc/cron.${BASE}
test -d $CRONDIR || continue
if [ -e ${LOCKDIR}/cron.$BASE ]
then
case $BASE in
hourly)
#>= 1 hour, 5 min -=> +65 min
TIME="-cmin +65" ;;
daily)
#>= 1 day, 5 min -=> +1445 min
TIME="-cmin +1445" ;;
weekly)
#>= 1 week, 5 min -=> +10085 min
TIME="-cmin +10085" ;;
monthly)
#>= 31 days, 5 min -=> +44645 min
TIME="-cmin +44645" ;;
esac
find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \;
fi
# if there is no touch file, make one then run the scripts
if [ ! -e ${LOCKDIR}/cron.$BASE ]
then
touch ${LOCKDIR}/cron.$BASE
set +e
for SCRIPT in $CRONDIR/*
do
if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then
$SCRIPT
fi
done
fi
done
# Clean out bogus cron.$BASE files with future times
touch ${LOCKDIR}
find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \;
@@ -0,0 +1,24 @@
--- vixie-cron-4.1/crontab.c.CAN-2005-1038 2005-04-14 18:39:04.356618000 -0400
+++ vixie-cron-4.1/crontab.c 2005-04-14 18:43:50.262425000 -0400
@@ -497,6 +497,21 @@
ProgramName);
goto remove;
}
+
+ if ( (!S_ISREG(statbuf.st_mode))
+ ||(S_ISLNK(statbuf.st_mode))
+ ||(S_ISDIR(statbuf.st_mode))
+ ||(S_ISCHR(statbuf.st_mode))
+ ||(S_ISBLK(statbuf.st_mode))
+ ||(S_ISFIFO(statbuf.st_mode))
+ ||(S_ISSOCK(statbuf.st_mode))
+ )
+ {
+ fprintf(stderr, "%s: illegal crontab\n",
+ ProgramName);
+ goto remove;
+ }
+
fprintf(stderr, "%s: installing new crontab\n", ProgramName);
fclose(NewCrontab);
NewCrontab=fopen(Filename,"r+");
@@ -0,0 +1,12 @@
--- entry.c 2004-08-27 20:09:34.000000000 +0200
+++ /root/entry.c 2004-09-26 14:41:46.929137000 +0200
@@ -336,7 +336,8 @@
/* If the first character of the command is '-' it is a cron option.
*/
- while ((ch = get_char(file)) == '-') {
+ ch = get_char(file);
+ while (ch == '-') {
switch (ch = get_char(file)) {
case 'q':
e->flags |= DONT_LOG;
@@ -0,0 +1,3 @@
# If for any reason you have users in the 'cron' group who should not
# be allowed to run crontab, add them to this file (one username per
# line)
@@ -0,0 +1,67 @@
--- vixie-cron-3.0.1.orig/Makefile Thu May 30 19:47:00 2002
+++ vixie-cron-3.0.1/Makefile Thu May 30 20:54:46 2002
@@ -55,7 +55,7 @@
INCLUDE = -I.
#INCLUDE =
#<<need getopt()>>
-LIBS =
+LIBS = -lpam
#<<optimize or debug?>>
OPTIM = $(RPM_OPT_FLAGS)
#OPTIM = -g
--- vixie-cron-3.0.1.orig/do_command.c Thu May 30 19:47:00 2002
+++ vixie-cron-3.0.1/do_command.c Thu May 30 20:55:50 2002
@@ -25,6 +25,18 @@
#include "cron.h"
+#include <security/pam_appl.h>
+static pam_handle_t *pamh = NULL;
+static const struct pam_conv conv = {
+ NULL
+};
+#define PAM_FAIL_CHECK if (retcode != PAM_SUCCESS) { \
+ fprintf(stderr,"\n%s\n",pam_strerror(pamh, retcode)); \
+ syslog(LOG_ERR,"%s",pam_strerror(pamh, retcode)); \
+ pam_end(pamh, retcode); exit(1); \
+ }
+
+
static void child_process(entry *, user *);
static int safe_p(const char *, const char *);
@@ -65,6 +77,7 @@
int stdin_pipe[2], stdout_pipe[2];
char *input_data, *usernm, *mailto;
int children = 0;
+ int retcode = 0;
Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd))
@@ -134,6 +147,16 @@
*p = '\0';
}
+
+ retcode = pam_start("cron", usernm, &conv, &pamh);
+ PAM_FAIL_CHECK;
+ retcode = pam_acct_mgmt(pamh, PAM_SILENT);
+ PAM_FAIL_CHECK;
+ retcode = pam_open_session(pamh, PAM_SILENT);
+ PAM_FAIL_CHECK;
+ retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED | PAM_SILENT);
+ PAM_FAIL_CHECK;
+
/* fork again, this time so we can exec the user's command.
*/
switch (vfork()) {
@@ -507,6 +530,9 @@
Debug(DPROC, (", dumped core"))
Debug(DPROC, ("\n"))
}
+ pam_setcred(pamh, PAM_DELETE_CRED | PAM_SILENT);
+ retcode = pam_close_session(pamh, PAM_SILENT);
+ pam_end(pamh, retcode);
}
static int