Skip to content

Commit

Permalink
envidir: add -p option to set PATH before call to execve
Browse files Browse the repository at this point in the history
1. daemontools.spec, debian/control: use libqmail-devel > 1.3 for
   pathexec_env_plus() function in libqmail
2. envdir.c: added -p option to set PATH variable before the call
   to execve
3. Updated envdir, supervise, svscan man pages
  • Loading branch information
mbhangui committed Nov 12, 2024
1 parent ee707e6 commit 413489e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 20 deletions.
4 changes: 2 additions & 2 deletions daemontools-x/daemontools.spec.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
#
# $Id: daemontools.spec.in,v 1.49 2024-07-01 20:11:30+05:30 Cprogrammer Exp mbhangui $
# $Id: daemontools.spec.in,v 1.50 2024-11-12 16:02:00+05:30 Cprogrammer Exp mbhangui $
%undefine _missing_build_ids_terminate_build
%global _unpackaged_files_terminate_build 1

Expand Down Expand Up @@ -78,7 +78,7 @@ BuildRequires: mariadb-connector-c-devel
%else
BuildRequires: mysql-devel
%endif
BuildRequires: libqmail-devel
BuildRequires: libqmail-devel > 1.3

##################################### OBS ####################################
%if %build_on_obs == 1
Expand Down
2 changes: 1 addition & 1 deletion daemontools-x/debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Section: admin
Priority: extra
Maintainer: @email@
Standards-Version: 3.9.1
Build-Depends: cdbs, debhelper (>= 9), gcc, automake, libqmail-dev, m4, gawk
Build-Depends: cdbs, debhelper (>= 9), gcc, automake, libqmail-dev (>= 1.4), m4, gawk
Homepage: https://github.com/indimail/indimail-mta

Package: daemontools
Expand Down
4 changes: 4 additions & 0 deletions daemontools-x/doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
17. supervise.c: prevent restart of service on SIGTERM
18. svscan.c: added killsvc function to shutdown non-log and log services
19. svscan.c: refactored shutdown handling
- 12/11/2024
20. daemontools.spec, debian/control: use libqmail-devel > 1.3 for
pathexec_env_plus() function in libqmail
21. envdir.c: added -p option to set PATH variable before the call to execve

* Tue Aug 06 2024 12:48:42 +0000 Manvendra Bhangui <daemontools@indimail.org> 1.1.5-1.1%{?dist}
Release 1.1.5-1.1 Start 05/02/2024 End 06/08/2024
Expand Down
21 changes: 19 additions & 2 deletions daemontools-x/envdir.8
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ envdir \- runs another program with environment modified according to files
in a specified directory.

.SH SYNOPSIS
\fBenvdir\fR [ -cwi ] \fId\fR \fIchild\fR
\fBenvdir\fR [ -cwip ] \fId\fR \fIchild\fR

.SH DESCRIPTION
\fId\fR is a single argument. \fIchild\fR consists of one or more
arguments.

\fBenvdir\fR sets various environment variables as specified by files in
the directory named \fId\fR. It then runs \fIchild\R.
the directory named \fId\fR. It then runs \fIchild\fR with the environment
variables passed to \fBexecve\fR(2). These environment variables are not
set before the call to \fBexecve\fR(2). You can however set these
environment variables before the call to \fBexecve\fR(2) like this

.EX
envdir \fId\fR envdir \fId\fR \fIchild\fR
.EE

For the \fBPATH\fR variable to be set before the call to \fBexecve\fR(2),
you can use the \fB\-p\fR option.

If \fId\fR contains a file named \fIs\fR whose first line is \fIt\fR,
\fBenvdir\fR removes an environment variable named \fIs\fR if one exists,
Expand Down Expand Up @@ -80,6 +90,13 @@ This option ignores if it cannot read a file in \fId\fR. This allows the
system administrator to specify different access to different users for
any environment variable

.TP
.B \-p
This options sets the PATH environment variable if defined in \fId\fR
before the call to \fBexecve\fR(2). This may be useful for \fBexecve\fR(2)
to be able to execute \fIchild\fR passed to \fBenvdir\fR without the full
path.

.SH EXIT CODES
\fBenvdir\fR exits 111 if it has trouble reading \fId\fR, if it runs out of
memory for environment variables, or if it cannot run \fIchild\fR.
Expand Down
16 changes: 12 additions & 4 deletions daemontools-x/envdir.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/*
* $Log: envdir.c,v $
* Revision 1.9 2024-11-12 16:03:28+05:30 Cprogrammer
* added -p option to set PATH variable before the call to execve
*
* Revision 1.8 2024-05-09 22:39:36+05:30 mbhangui
* fix discarded-qualifier compiler warnings
*
Expand Down Expand Up @@ -55,10 +58,10 @@ main(int argc, char **argv)
const char *fn, *err = (char *) 0;
char **e;
int i, opt, warn_on_error = 0, ignore_unreadable = 0,
unreadable_count = 0;
unreadable_count = 0, set_path = 0, j = 0;

orig_env = environ;
while ((opt = getopt(argc, argv, "cwi")) != opteof) {
while ((opt = getopt(argc, argv, "cwip")) != opteof) {
switch (opt)
{
case 'c':
Expand All @@ -70,6 +73,9 @@ main(int argc, char **argv)
case 'i':
ignore_unreadable = 1;
break;
case 'p':
set_path = 1;
break;
default:
die_usage(0);
break;
Expand All @@ -87,7 +93,9 @@ main(int argc, char **argv)
strerr_die5sys(111, FATAL, envdir_str(i), ": ", err, ": ");
strerr_warn5(WARN, envdir_str(i), ": ", err, ": ", &strerr_sys);
}
if (i || (!ignore_unreadable && unreadable_count)) { /*- original envdir behaviour */
if (set_path)
j = pathexec_env_plus("PATH=", 5);
if (i || j || (!ignore_unreadable && unreadable_count)) { /*- original envdir behaviour */
pathexec_clear(); /*- clear environment variables picked by pathexec */
environ = orig_env;
}
Expand All @@ -103,7 +111,7 @@ main(int argc, char **argv)
void
getversion_envdir_main_c()
{
const char *x = "$Id: envdir.c,v 1.8 2024-05-09 22:39:36+05:30 mbhangui Exp mbhangui $";
const char *x = "$Id: envdir.c,v 1.9 2024-11-12 16:03:28+05:30 Cprogrammer Exp mbhangui $";

x++;
}
8 changes: 4 additions & 4 deletions daemontools-x/supervise.8
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ service. If the directory \fIrun/svscan\fR exists, \fBsupervise\fR creates
the directory \fIdir/supervise\fR in \fIrun/svscan\fR where \fIrun\fR is
either \fI/run\fR or \fI/var/run\fR tmpfs filesystem (depending on your
operating system). The directory \fIrun\fR/\fIsvscan\fR is created by
\fBsvscan\fR(8) when \fBDISABLE_RUN\fR isn't set. It also opens
\fIdir/supervise/lock\fR in exclusive mode to prevent multiple copies of
supervise run for the same service. It exits 100 if it cannot open
\fIdir/supervise/lock\fR. The directory \fIdir\fR must be writable to
\fBsvscan\fR(8) when \fBDISABLE_RUN\fR environment variable isn't set. It
also opens \fIdir/supervise/lock\fR in exclusive mode to prevent multiple
copies of supervise run for the same service. It exits 100 if it cannot
open \fIdir/supervise/lock\fR. The directory \fIdir\fR must be writable to
\fBsupervise\fR. This directory is used to maintain status information in
binary format and also create few named pipes. The status information can
be read by \fBsvstat\fR(8). If \fBDISABLE_RUN\fR is set, or if your system
Expand Down
14 changes: 7 additions & 7 deletions daemontools-x/svscan.9
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.\" vim: tw=75
.TH svscan 8
.SH NAME
svscan \- starts and monitors a collection of services
svscan \- start and monitor a collection of services

.SH SYNOPSIS
.B svscan [ -vs ] [-n count] [ \fIscandir\fR ]

.SH DESCRIPTION
\fBsvscan\fR(8) starts one \fBsupervise\fR(8) process for each subdirectory
of the current directory, up to a limit of subdirectories as default. You
can change the default by passing -n option, in which case \fBsvscan\fR
will allocate memory for \fIcount\fR service slots. You can override using
current directory by passing \fIscandir\fR as an argument. If \fBsvscan\fR
is given a command-line argument \fIdir\fR, it switches to that directory
when it starts.
of the current directory, up to a limit of 1000 subdirectories as default.
You can change the default by using -n \fIcount\fR, in which case
\fBsvscan\fR will allocate memory for \fIcount\fR service slots. You can
override using current directory by passing \fIscandir\fR as an argument.
If \fBsvscan\fR is given a command-line argument \fIdir\fR, it switches to
that directory when it starts.

\fBsvscan\fR skips subdirectory names starting with dots. \fBsupervise\fR
must be in \fBsvscan\fR's path. If the environment variable \fBSETSID\fR is
Expand Down

0 comments on commit 413489e

Please sign in to comment.