Christian Wiese
14 years ago
committed by
Christian Wiese
5 changed files with 135 additions and 747 deletions
@ -1,116 +0,0 @@ |
|||||||
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
||||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
||||||
#
|
|
||||||
# Filename: package/.../autofs/2-fg.patch
|
|
||||||
# Copyright (C) 2006 The T2 SDE Project
|
|
||||||
#
|
|
||||||
# More information can be found in the files COPYING and README.
|
|
||||||
#
|
|
||||||
# This patch file is dual-licensed. It is available under the license the
|
|
||||||
# patched project is licensed under, as long as it is an OpenSource license
|
|
||||||
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
|
||||||
# of the GNU General Public License as published by the Free Software
|
|
||||||
# Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
# version.
|
|
||||||
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
||||||
|
|
||||||
add -f --foreground option which prevents automount from daemonizing
|
|
||||||
adapted from: http://lkml.org/lkml/2004/10/7/217 by Denis Vlasenko
|
|
||||||
|
|
||||||
diff -urpN autofs-4.1.4/daemon/automount.c autofs-4.1.4-fg/daemon/automount.c
|
|
||||||
--- autofs-4.1.4/daemon/automount.c 2005-03-06 06:43:55.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-fg/daemon/automount.c 2006-02-12 10:21:38.000000000 -0300
|
|
||||||
@@ -60,6 +60,7 @@ static int submount = 0;
|
|
||||||
|
|
||||||
int do_verbose = 0; /* Verbose feedback option */
|
|
||||||
int do_debug = 0; /* Enable full debug output */
|
|
||||||
+int daemonize = 1; /* Shall we daemonize? */
|
|
||||||
|
|
||||||
sigset_t ready_sigs; /* signals only accepted in ST_READY */
|
|
||||||
sigset_t lock_sigs; /* signals blocked for locking */
|
|
||||||
@@ -1282,7 +1283,7 @@ static void become_daemon(void)
|
|
||||||
chdir("/");
|
|
||||||
|
|
||||||
/* Detach from foreground process */
|
|
||||||
- if (!submount) {
|
|
||||||
+ if (!submount && daemonize) {
|
|
||||||
pid = fork();
|
|
||||||
if (pid > 0)
|
|
||||||
exit(0);
|
|
||||||
@@ -1311,9 +1311,15 @@
|
|
||||||
* ouselves from the controling tty. This ensures we don't get unexpected
|
|
||||||
* signals. This call also sets us as the process group leader.
|
|
||||||
*/
|
|
||||||
- if (!submount && (setsid() == -1)) {
|
|
||||||
- crit("setsid: %m");
|
|
||||||
- exit(1);
|
|
||||||
+ if (!submount) {
|
|
||||||
+ if (daemonize && (setsid() == -1)) {
|
|
||||||
+ crit("setsid: %m");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+ if (!daemonize && (setpgrp() == -1)) {
|
|
||||||
+ crit("setpgrp: %m");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
my_pgrp = getpgrp();
|
|
||||||
|
|
||||||
@@ -1327,7 +1328,7 @@ static void become_daemon(void)
|
|
||||||
crit("redirecting file descriptors failed: %m");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
- close(nullfd);
|
|
||||||
+ if (nullfd > 2) close(nullfd);
|
|
||||||
|
|
||||||
/* Write pid file if requested */
|
|
||||||
if (pid_file) {
|
|
||||||
@@ -1379,7 +1380,19 @@ static unsigned long getnumopt(char *str
|
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
- fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
|
|
||||||
+ fprintf(stderr,
|
|
||||||
+ "Usage: %s [options] path map_type [args...]\n"
|
|
||||||
+ " -h --help this text\n"
|
|
||||||
+ " -p --pid-file f write process id to file f\n"
|
|
||||||
+ " -t --timeout n auto-unmount in n seconds (0-disable)\n"
|
|
||||||
+ " -f --foreground do not daemonize\n"
|
|
||||||
+ " -v --verbose be verbose\n"
|
|
||||||
+ " -d --debug be even more verbose\n"
|
|
||||||
+ " -V --version print version and exit\n"
|
|
||||||
+ /* " -g --ghost \n" */
|
|
||||||
+ /* " --submount \n" */
|
|
||||||
+ , program
|
|
||||||
+ );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
|
|
||||||
@@ -1666,6 +1679,7 @@ int main(int argc, char *argv[])
|
|
||||||
{"help", 0, 0, 'h'},
|
|
||||||
{"pid-file", 1, 0, 'p'},
|
|
||||||
{"timeout", 1, 0, 't'},
|
|
||||||
+ {"foreground", 0, 0, 'f'},
|
|
||||||
{"verbose", 0, 0, 'v'},
|
|
||||||
{"debug", 0, 0, 'd'},
|
|
||||||
{"version", 0, 0, 'V'},
|
|
||||||
@@ -1683,7 +1697,7 @@ int main(int argc, char *argv[])
|
|
||||||
ap.dir_created = 0; /* We haven't created the main directory yet */
|
|
||||||
|
|
||||||
opterr = 0;
|
|
||||||
- while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) {
|
|
||||||
+ while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'h':
|
|
||||||
usage();
|
|
||||||
@@ -1697,6 +1711,10 @@ int main(int argc, char *argv[])
|
|
||||||
ap.exp_timeout = getnumopt(optarg, opt);
|
|
||||||
break;
|
|
||||||
|
|
||||||
+ case 'f':
|
|
||||||
+ daemonize = 0;
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
case 'v':
|
|
||||||
do_verbose = 1;
|
|
||||||
break;
|
|
@ -1,625 +0,0 @@ |
|||||||
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
||||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
||||||
#
|
|
||||||
# Filename: package/.../autofs/3-syslog.patch
|
|
||||||
# Copyright (C) 2006 The T2 SDE Project
|
|
||||||
#
|
|
||||||
# More information can be found in the files COPYING and README.
|
|
||||||
#
|
|
||||||
# This patch file is dual-licensed. It is available under the license the
|
|
||||||
# patched project is licensed under, as long as it is an OpenSource license
|
|
||||||
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
|
||||||
# of the GNU General Public License as published by the Free Software
|
|
||||||
# Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
# version.
|
|
||||||
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
||||||
|
|
||||||
add -s --stderr option which makes automounter send all log output to stderr
|
|
||||||
adapted from: http://lkml.org/lkml/2004/10/7/217 by Denis Vlasenko
|
|
||||||
|
|
||||||
diff -urpN autofs-4.1.4-fg/daemon/automount.c autofs-4.1.4-syslog/daemon/automount.c
|
|
||||||
--- autofs-4.1.4-fg/daemon/automount.c 2006-02-12 10:21:38.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/daemon/automount.c 2006-02-12 10:22:03.000000000 -0300
|
|
||||||
@@ -39,7 +39,7 @@
|
|
||||||
#include <linux/auto_fs4.h>
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
-#define assert(x) do { if (!(x)) { syslog(LOG_CRIT, __FILE__ ":%d: assertion failed: " #x, __LINE__); } } while(0)
|
|
||||||
+#define assert(x) do { if (!(x)) { crit(__FILE__ ":%d: assertion failed: " #x, __LINE__); } } while(0)
|
|
||||||
#else
|
|
||||||
#define assert(x) do { } while(0)
|
|
||||||
#endif
|
|
||||||
@@ -62,6 +62,8 @@ int do_verbose = 0; /* Verbose feedback
|
|
||||||
int do_debug = 0; /* Enable full debug output */
|
|
||||||
int daemonize = 1; /* Shall we daemonize? */
|
|
||||||
|
|
||||||
+int log_stderr; /* Use stderr instead of syslog? */
|
|
||||||
+
|
|
||||||
sigset_t ready_sigs; /* signals only accepted in ST_READY */
|
|
||||||
sigset_t lock_sigs; /* signals blocked for locking */
|
|
||||||
sigset_t sigchld_mask;
|
|
||||||
@@ -160,7 +162,7 @@ static int umount_ent(const char *root,
|
|
||||||
umount_ok = 1;
|
|
||||||
|
|
||||||
if (umount_ok || is_smbfs) {
|
|
||||||
- rv = spawnll(LOG_DEBUG,
|
|
||||||
+ rv = spawnll(debug,
|
|
||||||
PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -314,13 +316,13 @@ static int do_umount_autofs(void)
|
|
||||||
struct stat st;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
- rv = spawnll(LOG_DEBUG,
|
|
||||||
+ rv = spawnll(debug,
|
|
||||||
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
|
|
||||||
if (rv & MTAB_NOTUPDATED) {
|
|
||||||
info("umount %s succeeded: "
|
|
||||||
"mtab not updated, retrying to clean\n",
|
|
||||||
ap.path);
|
|
||||||
- rv = spawnll(LOG_DEBUG,
|
|
||||||
+ rv = spawnll(debug,
|
|
||||||
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
|
|
||||||
}
|
|
||||||
ret = stat(ap.path, &st);
|
|
||||||
@@ -450,7 +452,7 @@ static int mount_autofs(char *path)
|
|
||||||
}
|
|
||||||
our_name[len] = '\0';
|
|
||||||
|
|
||||||
- if (spawnll(LOG_DEBUG, PATH_MOUNT, PATH_MOUNT,
|
|
||||||
+ if (spawnll(debug, PATH_MOUNT, PATH_MOUNT,
|
|
||||||
"-t", "autofs", "-o", options, our_name, path, NULL) != 0) {
|
|
||||||
crit("failed to mount autofs path %s", ap.path);
|
|
||||||
rmdir_path(ap.path);
|
|
||||||
@@ -542,7 +544,7 @@ static int send_fail(unsigned int wait_q
|
|
||||||
return 0;
|
|
||||||
debug("send_fail: token=%d\n", wait_queue_token);
|
|
||||||
if (ioctl(ap.ioctlfd, AUTOFS_IOC_FAIL, wait_queue_token) < 0) {
|
|
||||||
- syslog(LOG_ERR, "AUTOFS_IOC_FAIL: %m");
|
|
||||||
+ error("AUTOFS_IOC_FAIL: %m");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
@@ -948,7 +950,7 @@ static int get_pkt(int fd, union autofs_
|
|
||||||
if (poll(fds, 2, -1) == -1) {
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
- syslog(LOG_ERR, "get_pkt: poll failed: %m");
|
|
||||||
+ error("get_pkt: poll failed: %s", strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1277,7 +1279,6 @@ static void become_daemon(void)
|
|
||||||
{
|
|
||||||
FILE *pidfp;
|
|
||||||
pid_t pid;
|
|
||||||
- int nullfd;
|
|
||||||
|
|
||||||
/* Don't BUSY any directories unnecessarily */
|
|
||||||
chdir("/");
|
|
||||||
@@ -1293,9 +1294,12 @@ static void become_daemon(void)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- /* Open syslog */
|
|
||||||
- openlog("automount", LOG_PID, LOG_DAEMON);
|
|
||||||
+ /* Initialize logging subsystem */
|
|
||||||
+ if(!log_stderr) {
|
|
||||||
+ log_to_syslog();
|
|
||||||
+ } else {
|
|
||||||
+ log_to_stderr();
|
|
||||||
+ }
|
|
||||||
|
|
||||||
/* Initialize global data */
|
|
||||||
my_pid = getpid();
|
|
||||||
@@ -1317,26 +1321,14 @@ static void become_daemon(void)
|
|
||||||
}
|
|
||||||
my_pgrp = getpgrp();
|
|
||||||
|
|
||||||
- /* Redirect all our file descriptors to /dev/null */
|
|
||||||
- if ((nullfd = open("/dev/null", O_RDWR)) < 0) {
|
|
||||||
- crit("cannot open /dev/null: %m");
|
|
||||||
- exit(1);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (dup2(nullfd, STDIN_FILENO) < 0 ||
|
|
||||||
- dup2(nullfd, STDOUT_FILENO) < 0 || dup2(nullfd, STDERR_FILENO) < 0) {
|
|
||||||
- crit("redirecting file descriptors failed: %m");
|
|
||||||
- exit(1);
|
|
||||||
- }
|
|
||||||
- if (nullfd > 2) close(nullfd);
|
|
||||||
-
|
|
||||||
/* Write pid file if requested */
|
|
||||||
if (pid_file) {
|
|
||||||
if ((pidfp = fopen(pid_file, "wt"))) {
|
|
||||||
fprintf(pidfp, "%lu\n", (unsigned long) my_pid);
|
|
||||||
fclose(pidfp);
|
|
||||||
} else {
|
|
||||||
- warn("failed to write pid file %s: %m", pid_file);
|
|
||||||
+ warn("failed to write pid file %s: %s", pid_file,
|
|
||||||
+ strerror(errno));
|
|
||||||
pid_file = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1386,6 +1378,7 @@ static void usage(void)
|
|
||||||
" -p --pid-file f write process id to file f\n"
|
|
||||||
" -t --timeout n auto-unmount in n seconds (0-disable)\n"
|
|
||||||
" -f --foreground do not daemonize\n"
|
|
||||||
+ " -s --stderr log to stderr instead of syslog\n"
|
|
||||||
" -v --verbose be verbose\n"
|
|
||||||
" -d --debug be even more verbose\n"
|
|
||||||
" -V --version print version and exit\n"
|
|
||||||
@@ -1680,6 +1673,7 @@ int main(int argc, char *argv[])
|
|
||||||
{"pid-file", 1, 0, 'p'},
|
|
||||||
{"timeout", 1, 0, 't'},
|
|
||||||
{"foreground", 0, 0, 'f'},
|
|
||||||
+ {"stderr", 0, 0, 's'},
|
|
||||||
{"verbose", 0, 0, 'v'},
|
|
||||||
{"debug", 0, 0, 'd'},
|
|
||||||
{"version", 0, 0, 'V'},
|
|
||||||
@@ -1697,7 +1691,7 @@ int main(int argc, char *argv[])
|
|
||||||
ap.dir_created = 0; /* We haven't created the main directory yet */
|
|
||||||
|
|
||||||
opterr = 0;
|
|
||||||
- while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
|
|
||||||
+ while ((opt = getopt_long(argc, argv, "+hp:t:fsvdVg", long_options, NULL)) != EOF) {
|
|
||||||
switch (opt) {
|
|
||||||
case 'h':
|
|
||||||
usage();
|
|
||||||
@@ -1715,6 +1709,10 @@ int main(int argc, char *argv[])
|
|
||||||
daemonize = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
+ case 's':
|
|
||||||
+ log_stderr = 1;
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
case 'v':
|
|
||||||
do_verbose = 1;
|
|
||||||
break;
|
|
||||||
@@ -1739,7 +1737,7 @@ int main(int argc, char *argv[])
|
|
||||||
}
|
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
|
||||||
- fprintf(stderr, "%s: This program must be run by root.\n", program);
|
|
||||||
+ fprintf(stderr, "%s: This program must be run by root\n", program);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1766,9 +1764,9 @@ int main(int argc, char *argv[])
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (mapargc) {
|
|
||||||
int i;
|
|
||||||
- syslog(LOG_DEBUG, "Map argc = %d", mapargc);
|
|
||||||
+ debug("Map argc = %d", mapargc);
|
|
||||||
for (i = 0; i < mapargc; i++)
|
|
||||||
- syslog(LOG_DEBUG, "Map argv[%d] = %s", i, mapargv[i]);
|
|
||||||
+ debug("Map argv[%d] = %s", i, mapargv[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
diff -urpN autofs-4.1.4-fg/daemon/spawn.c autofs-4.1.4-syslog/daemon/spawn.c
|
|
||||||
--- autofs-4.1.4-fg/daemon/spawn.c 2005-02-10 09:56:53.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/daemon/spawn.c 2006-02-12 10:22:03.000000000 -0300
|
|
||||||
@@ -199,7 +199,7 @@ out:
|
|
||||||
|
|
||||||
#define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
|
|
||||||
|
|
||||||
-static int do_spawn(int logpri, int use_lock, const char *prog, const char *const *argv)
|
|
||||||
+static int do_spawn(logger* log, int use_lock, const char *prog, const char *const *argv)
|
|
||||||
{
|
|
||||||
pid_t f;
|
|
||||||
int status, pipefd[2];
|
|
||||||
@@ -260,7 +260,7 @@ static int do_spawn(int logpri, int use_
|
|
||||||
while (errp && (p = memchr(sp, '\n', errp))) {
|
|
||||||
*p++ = '\0';
|
|
||||||
if (sp[0]) /* Don't output empty lines */
|
|
||||||
- syslog(logpri, ">> %s", sp);
|
|
||||||
+ log(">> %s", sp);
|
|
||||||
errp -= (p - sp);
|
|
||||||
sp = p;
|
|
||||||
}
|
|
||||||
@@ -271,7 +271,7 @@ static int do_spawn(int logpri, int use_
|
|
||||||
if (errp >= ERRBUFSIZ) {
|
|
||||||
/* Line too long, split */
|
|
||||||
errbuf[errp] = '\0';
|
|
||||||
- syslog(logpri, ">> %s", errbuf);
|
|
||||||
+ log(">> %s", errbuf);
|
|
||||||
errp = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -281,7 +281,7 @@ static int do_spawn(int logpri, int use_
|
|
||||||
if (errp > 0) {
|
|
||||||
/* End of file without \n */
|
|
||||||
errbuf[errp] = '\0';
|
|
||||||
- syslog(logpri, ">> %s", errbuf);
|
|
||||||
+ log(">> %s", errbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (waitpid(f, &status, 0) != f)
|
|
||||||
@@ -296,12 +296,12 @@ static int do_spawn(int logpri, int use_
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-int spawnv(int logpri, const char *prog, const char *const *argv)
|
|
||||||
+int spawnv(logger* log, const char *prog, const char *const *argv)
|
|
||||||
{
|
|
||||||
- return do_spawn(logpri, 0, prog, argv);
|
|
||||||
+ return do_spawn(log, 0, prog, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
-int spawnl(int logpri, const char *prog, ...)
|
|
||||||
+int spawnl(logger* log, const char *prog, ...)
|
|
||||||
{
|
|
||||||
va_list arg;
|
|
||||||
int argc;
|
|
||||||
@@ -319,10 +319,10 @@ int spawnl(int logpri, const char *prog,
|
|
||||||
while ((*p++ = va_arg(arg, char *)));
|
|
||||||
va_end(arg);
|
|
||||||
|
|
||||||
- return do_spawn(logpri, 0, prog, (const char **) argv);
|
|
||||||
+ return do_spawn(log, 0, prog, (const char **) argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
-int spawnll(int logpri, const char *prog, ...)
|
|
||||||
+int spawnll(logger* log, const char *prog, ...)
|
|
||||||
{
|
|
||||||
va_list arg;
|
|
||||||
int argc;
|
|
||||||
@@ -340,5 +340,5 @@ int spawnll(int logpri, const char *prog
|
|
||||||
while ((*p++ = va_arg(arg, char *)));
|
|
||||||
va_end(arg);
|
|
||||||
|
|
||||||
- return do_spawn(logpri, 1, prog, (const char **) argv);
|
|
||||||
+ return do_spawn(log, 1, prog, (const char **) argv);
|
|
||||||
}
|
|
||||||
diff -urpN autofs-4.1.4-fg/include/automount.h autofs-4.1.4-syslog/include/automount.h
|
|
||||||
--- autofs-4.1.4-fg/include/automount.h 2005-01-26 10:03:02.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/include/automount.h 2006-02-12 10:22:03.000000000 -0300
|
|
||||||
@@ -117,13 +117,30 @@ struct autofs_point {
|
|
||||||
|
|
||||||
extern struct autofs_point ap;
|
|
||||||
|
|
||||||
+ /* log notification */
|
|
||||||
+
|
|
||||||
+extern int do_verbose;
|
|
||||||
+extern int do_debug;
|
|
||||||
+
|
|
||||||
+typedef void logger(const char* msg, ...);
|
|
||||||
+
|
|
||||||
+extern void (*info)(const char* msg, ...);
|
|
||||||
+extern void (*notice)(const char* msg, ...);
|
|
||||||
+extern void (*warn)(const char* msg, ...);
|
|
||||||
+extern void (*error)(const char* msg, ...);
|
|
||||||
+extern void (*crit)(const char* msg, ...);
|
|
||||||
+extern void (*debug)(const char* msg, ...);
|
|
||||||
+
|
|
||||||
+void log_to_syslog();
|
|
||||||
+void log_to_stderr();
|
|
||||||
+
|
|
||||||
/* Standard function used by daemon or modules */
|
|
||||||
|
|
||||||
int aquire_lock(void);
|
|
||||||
void release_lock(void);
|
|
||||||
-int spawnll(int logpri, const char *prog, ...);
|
|
||||||
-int spawnl(int logpri, const char *prog, ...);
|
|
||||||
-int spawnv(int logpri, const char *prog, const char *const *argv);
|
|
||||||
+int spawnll(logger *log, const char *prog, ...);
|
|
||||||
+int spawnl(logger *log, const char *prog, ...);
|
|
||||||
+int spawnv(logger *log, const char *prog, const char *const *argv);
|
|
||||||
void reset_signals(void);
|
|
||||||
void ignore_signals(void);
|
|
||||||
void discard_pending(int sig);
|
|
||||||
@@ -282,25 +299,6 @@ int is_mounted(const char *table, const
|
|
||||||
int has_fstab_option(const char *path, const char *opt);
|
|
||||||
int allow_owner_mount(const char *);
|
|
||||||
|
|
||||||
-/* log notification */
|
|
||||||
-extern int do_verbose;
|
|
||||||
-extern int do_debug;
|
|
||||||
-
|
|
||||||
-#define info(msg, args...) \
|
|
||||||
-if (do_verbose || do_debug) \
|
|
||||||
- syslog(LOG_INFO, msg, ##args);
|
|
||||||
-
|
|
||||||
-#define warn(msg, args...) \
|
|
||||||
-if (do_verbose || do_debug) \
|
|
||||||
- syslog(LOG_WARNING, msg, ##args);
|
|
||||||
-
|
|
||||||
-#define error(msg, args...) syslog(LOG_ERR, msg, ##args);
|
|
||||||
-
|
|
||||||
-#define crit(msg, args...) syslog(LOG_CRIT, msg, ##args);
|
|
||||||
-
|
|
||||||
-#define debug(msg, args...) \
|
|
||||||
-if (do_debug) \
|
|
||||||
- syslog(LOG_DEBUG, msg, ##args);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
diff -urpN autofs-4.1.4-fg/lib/Makefile autofs-4.1.4-syslog/lib/Makefile
|
|
||||||
--- autofs-4.1.4-fg/lib/Makefile 2005-01-09 06:16:43.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/lib/Makefile 2006-02-12 11:06:37.000000000 -0300
|
|
||||||
@@ -12,7 +12,7 @@ RANLIB = /usr/bin/ranlib
|
|
||||||
SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c
|
|
||||||
RPCS = mount.h mount_clnt.c mount_xdr.c
|
|
||||||
OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o \
|
|
||||||
- cat_path.o rpc_subs.o mounts.o lock.o
|
|
||||||
+ cat_path.o rpc_subs.o mounts.o lock.o log.o
|
|
||||||
|
|
||||||
LIB = autofs.a
|
|
||||||
|
|
||||||
@@ -48,6 +48,10 @@ listmount.o: listmount.c
|
|
||||||
$(CC) $(CFLAGS) -o listmount.o -c listmount.c
|
|
||||||
$(STRIP) listmount.o
|
|
||||||
|
|
||||||
+log.o: log.c
|
|
||||||
+ $(CC) $(CFLAGS) -o log.o -c log.c
|
|
||||||
+ $(STRIP) log.o
|
|
||||||
+
|
|
||||||
install: all
|
|
||||||
|
|
||||||
clean:
|
|
||||||
diff -urpN autofs-4.1.4-fg/lib/log.c autofs-4.1.4-syslog/lib/log.c
|
|
||||||
--- autofs-4.1.4-fg/lib/log.c 1969-12-31 21:00:00.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/lib/log.c 2006-02-12 10:22:03.000000000 -0300
|
|
||||||
@@ -0,0 +1,116 @@
|
|
||||||
+#include <stdarg.h>
|
|
||||||
+#include <stdio.h>
|
|
||||||
+#include <syslog.h>
|
|
||||||
+#include <unistd.h>
|
|
||||||
+#include <fcntl.h> /* open() */
|
|
||||||
+#include <stdlib.h> /* exit() */
|
|
||||||
+
|
|
||||||
+#include "automount.h"
|
|
||||||
+
|
|
||||||
+static void null(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void (*info)(const char* msg, ...) = null;
|
|
||||||
+void (*notice)(const char* msg, ...) = null;
|
|
||||||
+void (*warn)(const char* msg, ...) = null;
|
|
||||||
+void (*error)(const char* msg, ...) = null;
|
|
||||||
+void (*crit)(const char* msg, ...) = null;
|
|
||||||
+void (*debug)(const char* msg, ...) = null;
|
|
||||||
+
|
|
||||||
+static void syslog_debug(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_DEBUG, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void syslog_info(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_INFO, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void syslog_notice(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_NOTICE, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void syslog_warn(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_WARNING, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void syslog_err(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_ERR, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void syslog_crit(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ syslog(LOG_CRIT, msg, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void to_stderr(const char *msg, ...)
|
|
||||||
+{
|
|
||||||
+ va_list ap;
|
|
||||||
+ va_start(ap, msg);
|
|
||||||
+ vfprintf(stderr, msg, ap);
|
|
||||||
+ fputc('\n',stderr);
|
|
||||||
+ va_end(ap);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void log_to_syslog()
|
|
||||||
+{
|
|
||||||
+ int nullfd;
|
|
||||||
+
|
|
||||||
+ openlog("automount", LOG_PID, LOG_DAEMON);
|
|
||||||
+ if (do_debug) debug = syslog_debug;
|
|
||||||
+ if (do_verbose || do_debug) {
|
|
||||||
+ info = syslog_info;
|
|
||||||
+ notice = syslog_notice;
|
|
||||||
+ warn = syslog_warn;
|
|
||||||
+ }
|
|
||||||
+ error = syslog_err;
|
|
||||||
+ crit = syslog_crit;
|
|
||||||
+
|
|
||||||
+ /* Redirect all our file descriptors to /dev/null */
|
|
||||||
+ nullfd = open("/dev/null", O_RDWR);
|
|
||||||
+ if (nullfd < 0) {
|
|
||||||
+ crit("cannot open /dev/null: %m");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+ if (dup2(nullfd, STDIN_FILENO) < 0 ||
|
|
||||||
+ dup2(nullfd, STDOUT_FILENO) < 0 || dup2(nullfd, STDERR_FILENO) < 0) {
|
|
||||||
+ crit("redirecting file descriptors failed: %m");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+ if (nullfd > 2) close(nullfd);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void log_to_stderr()
|
|
||||||
+{
|
|
||||||
+ if (do_debug) debug = to_stderr;
|
|
||||||
+ if (do_verbose || do_debug) {
|
|
||||||
+ info = to_stderr;
|
|
||||||
+ notice = to_stderr;
|
|
||||||
+ warn = to_stderr;
|
|
||||||
+ }
|
|
||||||
+ error = to_stderr;
|
|
||||||
+ crit = to_stderr;
|
|
||||||
+}
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/lookup_yp.c autofs-4.1.4-syslog/modules/lookup_yp.c
|
|
||||||
--- autofs-4.1.4-fg/modules/lookup_yp.c 2005-02-10 07:59:59.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/modules/lookup_yp.c 2006-02-12 10:22:03.000000000 -0300
|
|
||||||
@@ -69,7 +69,7 @@ int lookup_init(const char *mapfmt, int
|
|
||||||
/* This should, but doesn't, take a const char ** */
|
|
||||||
err = yp_get_default_domain((char **) &ctxt->domainname);
|
|
||||||
if (err) {
|
|
||||||
- crit(MODPREFIX "map %s: %s\n", ctxt->mapname,
|
|
||||||
+ crit(MODPREFIX "map %s: %s", ctxt->mapname,
|
|
||||||
yperr_string(err));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/mount_bind.c autofs-4.1.4-syslog/modules/mount_bind.c
|
|
||||||
--- autofs-4.1.4-fg/modules/mount_bind.c 2005-01-10 10:28:29.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/modules/mount_bind.c 2006-02-12 11:08:06.000000000 -0300
|
|
||||||
@@ -59,7 +59,7 @@ int mount_init(void **context)
|
|
||||||
if (lstat(tmp1, &st1) == -1)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
- err = spawnl(LOG_DEBUG,
|
|
||||||
+ err = spawnl(debug,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL);
|
|
||||||
|
|
||||||
if (err == 0 &&
|
|
||||||
@@ -69,7 +69,7 @@ int mount_init(void **context)
|
|
||||||
}
|
|
||||||
|
|
||||||
debug(MODPREFIX "bind_works = %d\n", bind_works);
|
|
||||||
- spawnl(LOG_DEBUG,
|
|
||||||
+ spawnl(debug,
|
|
||||||
PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL);
|
|
||||||
|
|
||||||
out:
|
|
||||||
@@ -131,7 +131,7 @@ int mount_mount(const char *root, const
|
|
||||||
"calling mount --bind " SLOPPY " -o %s %s %s",
|
|
||||||
options, what, fullpath);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "--bind",
|
|
||||||
SLOPPYOPT "-o", options,
|
|
||||||
what, fullpath, NULL);
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/mount_changer.c autofs-4.1.4-syslog/modules/mount_changer.c
|
|
||||||
--- autofs-4.1.4-fg/modules/mount_changer.c 2005-01-09 06:16:43.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/modules/mount_changer.c 2006-02-12 11:09:46.000000000 -0300
|
|
||||||
@@ -68,7 +68,7 @@ int mount_mount(const char *root, const
|
|
||||||
|
|
||||||
debug(MODPREFIX "calling umount %s", what);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_DEBUG,
|
|
||||||
+ err = spawnll(debug,
|
|
||||||
PATH_UMOUNT, PATH_UMOUNT, what, NULL);
|
|
||||||
if (err) {
|
|
||||||
error(MODPREFIX "umount of %s failed (all may be unmounted)",
|
|
||||||
@@ -98,14 +98,14 @@ int mount_mount(const char *root, const
|
|
||||||
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
|
|
||||||
fstype, options, what, fullpath);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_DEBUG,
|
|
||||||
+ err = spawnll(debug,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
|
|
||||||
SLOPPYOPT "-o", options, what, fullpath, NULL);
|
|
||||||
} else {
|
|
||||||
debug(MODPREFIX "calling mount -t %s %s %s",
|
|
||||||
fstype, what, fullpath);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_DEBUG, PATH_MOUNT, PATH_MOUNT,
|
|
||||||
+ err = spawnll(debug, PATH_MOUNT, PATH_MOUNT,
|
|
||||||
"-t", fstype, what, fullpath, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/mount_ext2.c autofs-4.1.4-syslog/modules/mount_ext2.c
|
|
||||||
--- autofs-4.1.4-fg/modules/mount_ext2.c 2005-01-10 10:28:29.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/modules/mount_ext2.c 2006-02-12 11:10:21.000000000 -0300
|
|
||||||
@@ -93,10 +93,10 @@ int mount_mount(const char *root, const
|
|
||||||
#endif
|
|
||||||
if (ro) {
|
|
||||||
debug(MODPREFIX "calling %s -n %s", fsck_prog, what);
|
|
||||||
- err = spawnl(LOG_DEBUG, fsck_prog, fsck_prog, "-n", what, NULL);
|
|
||||||
+ err = spawnl(debug, fsck_prog, fsck_prog, "-n", what, NULL);
|
|
||||||
} else {
|
|
||||||
debug(MODPREFIX "calling %s -p %s", fsck_prog, what);
|
|
||||||
- err = spawnl(LOG_DEBUG, fsck_prog, fsck_prog, "-p", what, NULL);
|
|
||||||
+ err = spawnl(debug, fsck_prog, fsck_prog, "-p", what, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err & ~6) {
|
|
||||||
@@ -108,13 +108,13 @@ int mount_mount(const char *root, const
|
|
||||||
if (options) {
|
|
||||||
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
|
|
||||||
fstype, options, what, fullpath);
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
|
|
||||||
SLOPPYOPT "-o", options, what, fullpath, NULL);
|
|
||||||
} else {
|
|
||||||
debug(MODPREFIX "calling mount -t %s %s %s",
|
|
||||||
fstype, what, fullpath);
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
|
|
||||||
what, fullpath, NULL);
|
|
||||||
}
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/mount_generic.c autofs-4.1.4-syslog/modules/mount_generic.c
|
|
||||||
--- autofs-4.1.4-fg/modules/mount_generic.c 2005-01-10 10:28:29.000000000 -0300
|
|
||||||
+++ autofs-4.1.4-syslog/modules/mount_generic.c 2006-02-12 11:07:28.000000000 -0300
|
|
||||||
@@ -77,13 +77,13 @@ int mount_mount(const char *root, const
|
|
||||||
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
|
|
||||||
fstype, options, what, fullpath);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
|
|
||||||
SLOPPYOPT "-o", options, what, fullpath, NULL);
|
|
||||||
} else {
|
|
||||||
debug(MODPREFIX "calling mount -t %s %s %s",
|
|
||||||
fstype, what, fullpath);
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
|
|
||||||
what, fullpath, NULL);
|
|
||||||
}
|
|
||||||
diff -urpN autofs-4.1.4-fg/modules/mount_nfs.c autofs-4.1.4-syslog/modules/mount_nfs.c
|
|
||||||
--- autofs-4.1.4-fg/modules/mount_nfs.c 2005-04-05 08:42:42.000000000 -0400
|
|
||||||
+++ autofs-4.1.4-syslog/modules/mount_nfs.c 2006-02-12 11:09:09.000000000 -0300
|
|
||||||
@@ -449,14 +449,14 @@ int mount_mount(const char *root, const
|
|
||||||
debug(MODPREFIX "calling mount -t nfs " SLOPPY
|
|
||||||
" -o %s %s %s", nfsoptions, whatstr, fullpath);
|
|
||||||
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t",
|
|
||||||
"nfs", SLOPPYOPT "-o", nfsoptions,
|
|
||||||
whatstr, fullpath, NULL);
|
|
||||||
} else {
|
|
||||||
debug(MODPREFIX "calling mount -t nfs %s %s",
|
|
||||||
whatstr, fullpath);
|
|
||||||
- err = spawnll(LOG_NOTICE,
|
|
||||||
+ err = spawnll(notice,
|
|
||||||
PATH_MOUNT, PATH_MOUNT, "-t",
|
|
||||||
"nfs", whatstr, fullpath, NULL);
|
|
||||||
}
|
|
@ -0,0 +1,54 @@ |
|||||||
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||||||
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||||||
|
#
|
||||||
|
# Filename: package/.../autofs/autofs-5.0.5-heimdal.patch
|
||||||
|
# Copyright (C) 2011 The OpenSDE Project
|
||||||
|
#
|
||||||
|
# More information can be found in the files COPYING and README.
|
||||||
|
#
|
||||||
|
# This patch file is dual-licensed. It is available under the license the
|
||||||
|
# patched project is licensed under, as long as it is an OpenSource license
|
||||||
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
||||||
|
# of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
||||||
|
|
||||||
|
Description: Fix to build against heimdal
|
||||||
|
Origin: Gentoo Linux
|
||||||
|
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-fs/autofs/files/autofs-5.0.3-heimdal.patch
|
||||||
|
|
||||||
|
--- autofs-5.0.5/modules/cyrus-sasl.c.orig 2011-03-08 12:17:15.342696284 +0100
|
||||||
|
+++ autofs-5.0.5/modules/cyrus-sasl.c 2011-03-08 12:28:46.326696273 +0100
|
||||||
|
@@ -64,6 +64,15 @@
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * The type of a principal is different for MIT Krb5 and Heimdal.
|
||||||
|
+ * These macros are provided by Heimdal, and introduced here for MIT.
|
||||||
|
+ */
|
||||||
|
+#ifndef krb5_realm_length
|
||||||
|
+#define krb5_realm_length(r) ((r).length)
|
||||||
|
+#define krb5_realm_data(r) ((r).data)
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Once a krb5 credentials cache is setup, we need to set the KRB5CCNAME
|
||||||
|
* environment variable so that the library knows where to find it.
|
||||||
|
@@ -451,11 +460,11 @@
|
||||||
|
|
||||||
|
/* setup a principal for the ticket granting service */
|
||||||
|
ret = krb5_build_principal_ext(ctxt->krb5ctxt, &tgs_princ,
|
||||||
|
- krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->length,
|
||||||
|
- krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->data,
|
||||||
|
+ krb5_realm_length(*krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)),
|
||||||
|
+ krb5_realm_data(*krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)),
|
||||||
|
strlen(KRB5_TGS_NAME), KRB5_TGS_NAME,
|
||||||
|
- krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->length,
|
||||||
|
- krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->data,
|
||||||
|
+ krb5_realm_length(*krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)),
|
||||||
|
+ krb5_realm_data(*krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)),
|
||||||
|
0);
|
||||||
|
if (ret) {
|
||||||
|
error(logopt,
|
Loading…
Reference in new issue