Hello community,
here is the log from the commit of package pam_cifs
checked in at Wed Aug 2 16:29:37 CEST 2006.
--------
--- pam_cifs/pam_cifs.changes 2006-01-25 21:39:14.000000000 +0100
+++ pam_cifs/pam_cifs.changes 2006-08-02 15:54:34.000000000 +0200
@@ -1,0 +2,6 @@
+Wed Aug 2 15:53:50 CEST 2006 - mc@suse.de
+
+- update to version 0.43
+- Added options "windomain=<domain>" and "mount_home"
+
+-------------------------------------------------------------------
Old:
----
pam_cifs-0.4.tar.bz2
New:
----
pam_cifs-0.43.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ pam_cifs.spec ++++++
--- /var/tmp/diff_new_pack.ERpAPb/_old 2006-08-02 16:29:32.000000000 +0200
+++ /var/tmp/diff_new_pack.ERpAPb/_new 2006-08-02 16:29:32.000000000 +0200
@@ -1,11 +1,11 @@
#
-# spec file for package pam_cifs (Version 0.4)
+# spec file for package pam_cifs (Version 0.43)
#
-# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
-# Please submit bugfixes or comments via http://bugs.opensuse.org
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
@@ -15,10 +15,10 @@
License: GPL
Group: Productivity/Security
Autoreqprov: on
-Version: 0.4
-Release: 2
+Version: 0.43
+Release: 1
Summary: PAM module for mount/umount CIFS shares
-URL: http://sourceforge.net/projects/pam_cifs
+URL: http://sourceforge.net/projects/pam-cifs
Source: pam_cifs-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: pam
@@ -36,7 +36,7 @@
Wilhelm Meier meier@informatik.fh-kl.de
%prep
-%setup -q -n pam_cifs-%{version}
+%setup -q -n pam-cifs
%build
make
@@ -58,6 +58,9 @@
%attr(555,root,root)/%{_sbindir}/cifsumountd
%changelog -n pam_cifs
+* Wed Aug 02 2006 - mc@suse.de
+- update to version 0.43
+- Added options "windomain=<domain>" and "mount_home"
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Sep 12 2005 - schubi@suse.de
++++++ pam_cifs-0.4.tar.bz2 -> pam_cifs-0.43.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/AUTHORS new/pam-cifs/AUTHORS
--- old/pam_cifs-0.4/AUTHORS 2005-08-14 21:46:19.000000000 +0200
+++ new/pam-cifs/AUTHORS 2006-02-03 15:22:22.000000000 +0100
@@ -1,3 +1,8 @@
The original code is by
Wilhelm Meier (meier@informatik.fh-kl.de)
+
+Enhancements and Patches by
+
+* Björn Tore Sund
+
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/ChangeLog new/pam-cifs/ChangeLog
--- old/pam_cifs-0.4/ChangeLog 2005-08-14 21:47:05.000000000 +0200
+++ new/pam-cifs/ChangeLog 2006-02-03 15:21:17.000000000 +0100
@@ -1,3 +1,7 @@
+* Version 0.41
+ Added options "windomain=<domain>" and "mount_home"
+ Thanks to Björn Tore Sund
+
* Version 0.4
Added options and conversation support
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/INSTALL new/pam-cifs/INSTALL
--- old/pam_cifs-0.4/INSTALL 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/INSTALL 2006-08-02 11:58:44.000000000 +0200
@@ -1,4 +1,4 @@
-$Header: /cvsroot/pam-cifs/pam-cifs/INSTALL,v 1.4 2005/08/29 11:33:42 wimalopaan Exp $
+$Header: /cvsroot/pam-cifs/pam-cifs/INSTALL,v 1.7 2006/08/02 07:46:32 bjornts Exp $
pam_cifs - Linux-PAM module for mount/umount CIFS shares
@@ -84,6 +84,31 @@
if this option is given, the mount-point <prefix>/<username><suffix> will be created.
As a prerequisite, the directory <prefix> must already exist.
+10) windomain=<domain>
+
+specifies the windows-domain to mount from
+
+11) mount_home
+
+mount as users home. Can't be used together with make_mount_point.
+In addition, suffix must be set to first element of home directory
+path (regexp) for cifsumountd to work with this.
+
+12) options
+
+Options to mount.cifs, to be given behind -o to the mount command.
+Comma-separated list of options. Note that "options=serverino" is
+necessary with mount_home for KDE to work with a cifs-mounted home
+directory, for instance.
+
+13) background
+
+Sets whether the execution of the pam stack is to wait for the
+mount.cifs command to finish (background=0) or not (background=1).
+The latter is a lot faster, the former is useful if you've got
+processes starting at the end of the pam stack which depend on
+access to the mounted volume.
+
Requisites:
-----------
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/Makefile new/pam-cifs/Makefile
--- old/pam_cifs-0.4/Makefile 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/Makefile 2006-08-01 16:53:09.000000000 +0200
@@ -1,4 +1,4 @@
-# $Header: /cvsroot/pam-cifs/pam-cifs/Makefile,v 1.4 2005/08/29 11:33:42 wimalopaan Exp $
+# $Header: /cvsroot/pam-cifs/pam-cifs/Makefile,v 1.7 2006/08/01 14:13:03 bjornts Exp $
#
# pam_cifs - Linux-PAM module for mount/umount CIFS shares
#
@@ -20,7 +20,18 @@
#
CC=gcc
-CFLAGS+= -g -Wall -pedantic -std=c99 -fPIC
+CFLAGS += -g -Wall -pedantic -std=c99 -fPIC
+
+CFLAGS += -DDEFAULT_PATH_PREFIX='"/Home"'
+CFLAGS += -DDEFAULT_PATH_SUFFIX='""'
+CFLAGS += -DDEFAULT_SOURCE_PREFIX='""'
+CFLAGS += -DDEFAULT_SOURCE_SUFFIX='""'
+CFLAGS += -DDEFAULT_MOUNTER='"/sbin/mount.cifs"'
+CFLAGS += -DDEFAULT_MIN_UID=1000
+CFLAGS += -DDEFAULT_MAX_UID=65000
+CFLAGS += -DDEFAULT_LINK_NAME='""'
+CFLAGS += -DDEFAULT_DOMAIN='"Workgroup"'
+CFLAGS += -DDEFAULT_BACKGROUND=1
all: cifsumountd pam_cifs.so
@@ -58,6 +69,7 @@
install: all
cp pam_cifs.so /lib/security
cp cifsumountd /usr/sbin
+ cp init.d/cifsumountd /etc/init.d
clean:
- $(RM) *.o *.so *~ cifsumountd
\ No newline at end of file
+ $(RM) *.o *.so *~ cifsumountd
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/do_mount.c new/pam-cifs/do_mount.c
--- old/pam_cifs-0.4/do_mount.c 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/do_mount.c 2006-08-01 16:53:09.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/do_mount.c,v 1.2 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/do_mount.c,v 1.5 2006/08/01 14:13:03 bjornts Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -23,7 +23,8 @@
#include
int
-do_mount(char *source, char *target, const char *authtok, uid_t uid, gid_t gid, const char *user) {
+do_mount(char *source, char *target, char *options, const char *authtok,
+ uid_t uid, gid_t gid, const char *user, int background) {
slog("do_mount: %s should be mounted on %s", source, target);
char *argv[10];
@@ -33,7 +34,14 @@
argv[2] = target;
argv[3] = "-o";
argv[4] = (char *) malloc(LINE_MAX);
- snprintf(argv[4], LINE_MAX, "user=%s,uid=%d,gid=%d,dir_mode=0700,file_mode=0600", user, uid, gid);
+ if (strncmp(options, "", NAME_MAX) == 0) {
+ snprintf(argv[4], LINE_MAX, "user=%s,uid=%d,gid=%d,dir_mode=0700,file_mode=0600",
+ user, uid, gid);
+ }
+ else {
+ snprintf(argv[4], LINE_MAX, "%s,user=%s,uid=%d,gid=%d,dir_mode=0700,file_mode=0600",
+ options, user, uid, gid);
+ }
argv[5] = NULL;
char ret[LINE_MAX];
@@ -45,7 +53,7 @@
slog("setuid: %s", strerror(errno));
}
int retval = 0;
- if (pexec(DEFAULT_MOUNTER, argv, input, ret, LINE_MAX) < 0) {
+ if (pexec(DEFAULT_MOUNTER, argv, background, input, ret, LINE_MAX) < 0) {
retval = -1;
}
free(argv[0]);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/pam_cifs.c new/pam-cifs/pam_cifs.c
--- old/pam_cifs-0.4/pam_cifs.c 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/pam_cifs.c 2006-02-03 15:07:20.000000000 +0100
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/pam_cifs.c,v 1.3 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/pam_cifs.c,v 1.4 2006/02/03 14:07:20 wimalopaan Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -36,6 +36,8 @@
char *authtok = NULL;
slog_init("pam_cifs");
+
+ parse_options(argc, argv);
if ((retval = pam_get_item(pamh, PAM_AUTHTOK, (const void **)&authtok)) != PAM_SUCCESS) {
slog("authtok: %s\n", pam_strerror(pamh, retval));
@@ -108,6 +110,9 @@
PAM_EXTERN
int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv){
+
+ parse_options(argc, argv);
+
// We have to find the cifsumountd-daemon and it's socket to
// trigger. We can't send a SIGHUP-signal, because this function
// is run as unpriveleged user (normally) and cifsumountd runs as
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/pam_cifs.h new/pam-cifs/pam_cifs.h
--- old/pam_cifs-0.4/pam_cifs.h 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/pam_cifs.h 2006-08-01 16:58:51.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/pam_cifs.h,v 1.2 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/pam_cifs.h,v 1.5 2006/08/01 14:13:03 bjornts Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -29,14 +29,39 @@
#define BUFFER_SIZE 1024
#define MAX_MTAB 100
-#define DEFAULT_PATH_PREFIX "/home"
-#define DEFAULT_PATH_SUFFIX "/windows"
-#define DEFAULT_SOURCE_PREFIX "//zwo222-fs1.ds.fh-kl.de"
-#define DEFAULT_SOURCE_SUFFIX "$"
-#define DEFAULT_MOUNTER "/usr/bin/mount.cifs"
+#ifndef DEFAULT_PATH_PREFIX
+#define DEFAULT_PATH_PREFIX "undefined"
+#endif
+#ifndef DEFAULT_PATH_SUFFIX
+#define DEFAULT_PATH_SUFFIX "undefined"
+#endif
+#ifndef DEFAULT_SOURCE_PREFIX
+#define DEFAULT_SOURCE_PREFIX "undefined"
+#endif
+#ifndef DEFAULT_SOURCE_SUFFIX
+#define DEFAULT_SOURCE_SUFFIX ""
+#endif
+#ifndef DEFAULT_MOUNTER
+#define DEFAULT_MOUNTER "/sbin/mount.cifs"
+#endif
+#ifndef DEFAULT_DOMAIN
+#define DEFAULT_DOMAIN "undefined"
+#endif
+#ifndef DEFAULT_OPTIONS
+#define DEFAULT_OPTIONS "undefined"
+#endif
+#ifndef DEFAULT_MIN_UID
#define DEFAULT_MIN_UID 1000
+#endif
+#ifndef DEFAULT_MAX_UID
#define DEFAULT_MAX_UID 65000
+#endif
+#ifndef DEFAULT_LINK_NAME
#define DEFAULT_LINK_NAME ""
+#endif
+#ifndef DEFAULT_BACKGROUND
+#define DEFAULT_BACKGROUND 1
+#endif
#define CIFS_STRING "cifs"
#define CIFS_USERNAME "username"
@@ -57,6 +82,14 @@
// performed. This is to exclude root, operator and others.
uid_t min_uid;
uid_t max_uid;
+ // To authenticate towards servers that are Active Directory
+ // members, mount.cifs often needs to send the DOMAIN mount
+ // parameter. Put that value in this option. If the string
+ // is empty, only the username will be sent.
+ char domain[NAME_MAX + 1];
+ // General options to mount.cifs, comma-separated exactly as they
+ // would be given behind the -o option to mount.cifs
+ char options[NAME_MAX + 1];
// name of a link to be placed in the users HOME-directory to
// point to the mount-point. If it is there, it will NOT be
// overridden. If the string is empty (default), no link will be
@@ -66,6 +99,20 @@
// created. In detail: the <pathprefix> must exist and the pathcomponent
// <user><pathsuffix> will be created.
int make_mount_point;
+ // if mount_home == 1 the directory being attempted mounted will
+ // be the user's home directory. Does not currently work with
+ // make_mount_point, you need to use pam_mkhomedir for that.
+ // sourceprefix must be set to first path element (regexp) of the
+ // home directories for cifsumountd to work with this option.
+ int mount_home;
+ // if background == 0 the pam_cifs module will wait until the successful
+ // completion of the mount.cifs call before returning with success.
+ // if background == 1 the pam_cifs module will background the mount
+ // process and return with success before the mount.cifs call finishes.
+ // The latter is faster, the former is necessary if you need to be sure
+ // the mount process has finished before going to the next step in the
+ // pam stack.
+ int background;
};
typedef struct mtab mtab_t;
@@ -76,9 +123,9 @@
char options[PATH_MAX];
};
-int pexec(const char *cmdpath, char *argv[], char *input, char *output, size_t noutput);
+int pexec(const char *cmdpath, char *argv[], int background, char *input, char *output, size_t noutput);
void parse_options(int argc, const char **argv);
-int do_mount(char *source, char *target, const char *authtok, uid_t uid, gid_t gid, const char *user);
+int do_mount(char *source, char *target, char *domain, const char *authtok, uid_t uid, gid_t gid, const char *user, int background);
int already_mounted(char *path);
int read_mounts(mtab_t *mtab, size_t size);
void slog(const char *format, ...);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/pam_sm_open_session.c new/pam-cifs/pam_sm_open_session.c
--- old/pam_cifs-0.4/pam_sm_open_session.c 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/pam_sm_open_session.c 2006-08-01 16:58:52.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/pam_sm_open_session.c,v 1.3 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/pam_sm_open_session.c,v 1.6 2006/08/01 14:13:03 bjornts Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -61,6 +61,14 @@
int retval;
const char *user=NULL;
+// Putting this first test in until such time as I have time to fix
+// make_mount_point to not assume mount_points have to be subdirectories
+// of the home directory
+ if ((pam_cifs_options.make_mount_point == 1) && (pam_cifs_options.mount_home == 1)) {
+ slog("Cannot combine make_mount_point and mount_home\n");
+ return PAM_SESSION_ERR;
+ }
+
if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS) {
slog("open_session", pam_strerror(pamh, retval));
return cleanup(retval);
@@ -105,10 +113,15 @@
}
char target[PATH_MAX];
- strncpy(target, pam_cifs_options.pathprefix, PATH_MAX);
- strncat(target, "/", PATH_MAX);
- strncat(target, user, PATH_MAX);
- strncat(target, pam_cifs_options.pathsuffix, PATH_MAX);
+ if (pam_cifs_options.mount_home > 0) {
+ strncpy(target, pwd->pw_dir, PATH_MAX);
+ }
+ else {
+ strncpy(target, pam_cifs_options.pathprefix, PATH_MAX);
+ strncat(target, "/", PATH_MAX);
+ strncat(target, user, PATH_MAX);
+ strncat(target, pam_cifs_options.pathsuffix, PATH_MAX);
+ }
struct stat statbuf;
if (stat(target, &statbuf) < 0) {
@@ -141,7 +154,8 @@
strncat(source, user, PATH_MAX);
strncat(source, pam_cifs_options.sourcesuffix, PATH_MAX);
- if (do_mount(source, target, authtok, pwd->pw_uid, pwd->pw_gid, user) < 0) {
+ if (do_mount(source, target, pam_cifs_options.options, authtok, pwd->pw_uid,
+ pwd->pw_gid, user, pam_cifs_options.background) < 0) {
return cleanup(PAM_SESSION_ERR);
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/parse_options.c new/pam-cifs/parse_options.c
--- old/pam_cifs-0.4/parse_options.c 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/parse_options.c 2006-08-01 17:00:29.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/parse_options.c,v 1.2 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/parse_options.c,v 1.5 2006/08/01 14:13:03 bjornts Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -34,10 +34,14 @@
strncpy(pam_cifs_options.sourceprefix, DEFAULT_SOURCE_PREFIX, PATH_MAX);
strncpy(pam_cifs_options.pathsuffix, DEFAULT_PATH_SUFFIX, NAME_MAX);
strncpy(pam_cifs_options.pathprefix, DEFAULT_PATH_PREFIX, PATH_MAX);
+ strncpy(pam_cifs_options.domain, DEFAULT_DOMAIN, NAME_MAX);
+ strncpy(pam_cifs_options.options, DEFAULT_OPTIONS, NAME_MAX);
strncpy(pam_cifs_options.linkname, DEFAULT_LINK_NAME, NAME_MAX);
pam_cifs_options.debug = 0;
pam_cifs_options.make_mount_point = 0;
-
+ pam_cifs_options.mount_home = 0;
+ pam_cifs_options.background = DEFAULT_BACKGROUND;
+
// parse the command line
for(int i = 0; i < argc; i += 1) {
char *o = strdup(argv[i]);
@@ -64,6 +68,10 @@
pam_cifs_options.make_mount_point = 1;
}
+ if (strcmp(param, "mount_home") == 0) {
+ pam_cifs_options.mount_home = 1;
+ }
+
if (strcmp(param, "prefix") == 0) {
if (value != NULL) {
strncpy(pam_cifs_options.pathprefix, value, PATH_MAX);
@@ -88,8 +96,28 @@
}
}
+ if (strcmp(param, "windomain") == 0) {
+ if (value != NULL) {
+ strncpy(pam_cifs_options.options, "domain=", NAME_MAX);
+ strncat(pam_cifs_options.options, value, NAME_MAX);
+ strncat(pam_cifs_options.options, ",", NAME_MAX);
+ }
+ }
+
+ if (strcmp(param, "options") == 0) {
+ if (value != NULL) {
+ if (pam_cifs_options.options != NULL) {
+ strncat(pam_cifs_options.options, value, NAME_MAX);
+ }
+ else {
+ strncpy(pam_cifs_options.options, value, NAME_MAX);
+ }
+ }
+ }
+
if (strcmp(param, "linkname") == 0) {
if (value != NULL) {
+
strncpy(pam_cifs_options.linkname, value, NAME_MAX);
}
}
@@ -104,16 +132,26 @@
pam_cifs_options.min_uid = atoi(value);
}
}
+
+ if (strcmp(param, "background") == 0) {
+ if (value != NULL) {
+ pam_cifs_options.background = atoi(value);
+ }
+ }
}
if (pam_cifs_options.debug > 0) {
slog("pathprefix=%s", pam_cifs_options.pathprefix);
slog("pathsuffix=%s", pam_cifs_options.pathsuffix);
slog("sourceprefix=%s", pam_cifs_options.sourceprefix);
slog("sourcesuffix=%s", pam_cifs_options.sourcesuffix);
+// slog("windomain=%s", pam_cifs_options.domain);
+ slog("options=%s", pam_cifs_options.options);
slog("linkname=%s", pam_cifs_options.linkname);
slog("min_uid=%d", pam_cifs_options.min_uid);
slog("max_uid=%d", pam_cifs_options.max_uid);
slog("make_mount_point=%d", pam_cifs_options.make_mount_point);
+ slog("mount_home=%d", pam_cifs_options.mount_home);
+ slog("background=%d", pam_cifs_options.background);
}
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pam_cifs-0.4/pexec.c new/pam-cifs/pexec.c
--- old/pam_cifs-0.4/pexec.c 2005-08-29 13:33:42.000000000 +0200
+++ new/pam-cifs/pexec.c 2006-08-01 17:02:18.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pam-cifs/pam-cifs/pexec.c,v 1.5 2005/08/29 11:33:42 wimalopaan Exp $
+ * $Header: /cvsroot/pam-cifs/pam-cifs/pexec.c,v 1.7 2006/08/01 15:02:18 wimalopaan Exp $
*
* pam_cifs - Linux-PAM module for mount/umount CIFS shares
* Copyright (C) 2005 Wilhelm Meier (meier@informatik.fh-kl.de)
@@ -55,7 +55,7 @@
}
int
-pexec(const char *cmdpath, char *argv[], char *input, char *output, size_t noutput) {
+pexec(const char *cmdpath, char *argv[], int background, char *input, char *output, size_t noutput) {
pid_t cpid;
if (init() < 0) {
return -1;
@@ -87,22 +87,24 @@
slog("child:setsid: %s", strerror(errno));
exit(EXIT_FAILURE);
}
- // deamonize
- if ((cpid = fork()) < 0) {
- slog("fork: %s", strerror(errno));
- exit(EXIT_FAILURE);
- }
- else if (cpid > 0) { // parent
- exit(EXIT_SUCCESS);
+ // deamonize ?
+ if (background == 1) {
+ if ((cpid = fork()) < 0) {
+ slog("fork: %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ else if (cpid > 0) { // parent
+ exit(EXIT_SUCCESS);
+ }
}
- // child-child
+ // child-child if background, child otherwise
slog("exec: %s", cmdpath);
if (execvp(cmdpath, argv) < 0) {
slog("child:exec: %s", strerror(errno));
exit(EXIT_FAILURE);
}
- exit(EXIT_SUCCESS); // never reached
+ exit(EXIT_SUCCESS); // only reached if not background
}
else if (cpid > 0) { // Parent
if (close(down_fd[PIPE_READ]) < 0) {
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...