Re: [patch] extension of newsyslog

2001-10-13 Thread Toshihiko ARAI

+ <[EMAIL PROTECTED]>, Cyrille Lefevre wrote:

>> I add script call features to newsyslog.  This adds a one field to
>> newsyslog.conf.  When newsyslog processed log file, this can execute
>> arbitrary program.
>> 
>> Situation to assume:
>> * For the log file which cannot use signal.
>> * Cases to do statistical application for log file.

By the way, is there a user needing such a features really?  It may
not be general besides me.  If it is features to be comparatively
general, as for it, what specification method is desirable?

> it would be interresting to have the possibility to pass optional
> args to program.

The first patch does not consider it.  It specified merely pathname
of program.  I put a patch of a update version in the following URL.

 http://people.freebsd.org/~toshi/d/

> also, how about testing for the first (or the last) char to be &
> to run the program asynchronously ?

Command execution goes by way of /bin/sh in a new patch.
Asynchronous execution of program became possible.

> much better, always run the program asynchronously so that hanging
> programs (who knowns?) don't block the whole process. to do this,
> somewhere in main(), add something such as signal(SIGCHLD, SIG_IGN)
> and delete the while statment in post_prog().

I added some debug routine, and I tested it.  So far a problem does
not occur.

--
Toshihiko ARAI

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



[patch] extension of newsyslog

2001-10-08 Thread Toshihiko ARAI

Hello,

I add script call features to newsyslog.  This adds a one field to
newsyslog.conf.  When newsyslog processed log file, this can execute
arbitrary program.

Situation to assume:
 * For the log file which cannot use signal.
 * Cases to do statistical application for log file.

A sample entry of newsylog.conf:
# logfilename  [owner:group] mode count size when [ZB] [/pid_file] [sig_num] [/program]
/var/log/foo.log  bar:baz640  1 100  * Z   -  -  /etc/foo.sh

'-' is usable as a filler of null field.

I used similar enhanced function from the past.  I think that you can
apply this patch for 5-current.  In addition, I can prepare a patch
for 4-stable if it is necessary.

I ask for testing and a review of the following patches.

Thanks.
--
Toshihiko ARAI


Index: newsyslog.8
===
RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.8,v
retrieving revision 1.32
diff -u -r1.32 newsyslog.8
--- newsyslog.8 2001/07/30 15:17:17 1.32
+++ newsyslog.8 2001/09/30 08:54:07
@@ -76,7 +76,7 @@
 Each line of the file contains information about a particular log file
 that should be handled by
 .Nm .
-Each line has five mandatory fields and four optional fields, with
+Each line has five mandatory fields and five optional fields, with
 whitespace separating each field.  Blank lines or lines beginning with
 ``#'' are ignored.  The fields of the configuration file are as
 follows:
@@ -294,12 +294,28 @@
 .Ar signal_number
 is sent the process id contained in this
 file.  This field must start with "/" in order to be recognized
-properly.
+properly.  Same as
+.Ar flags
+field, you can use "-" for null field.
 .It Ar signal_number
 This optional field specifies
-the signal number will be sent to the daemon process.
+the signal number or signal name will be sent to the daemon process.
 By default
-a SIGHUP will be sent.
+a SIGHUP will be sent.  Same as
+.Ar flags
+field, you can use "-" for null field.
+.It Ar path_to_program
+This optional field specifies
+the path name of a script for postprocessing of log file. 
+This field must be specified with full path.
+And a file must be execute permission by specified
+.Ar owner
+and
+.Ar group .
+When
+.Ar path_to_program
+is called, new log file is given to the first argument, and old
+log file is given to the second argument.
 .El
 .Sh OPTIONS
 The following options can be used with
Index: newsyslog.c
===
RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.c,v
retrieving revision 1.37
diff -u -r1.37 newsyslog.c
--- newsyslog.c 2001/07/31 16:25:55 1.37
+++ newsyslog.c 2001/10/08 14:09:19
@@ -38,6 +38,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,6 +74,7 @@
 struct conf_entry {
char *log;  /* Name of the log */
char *pid_file; /* PID file */
+   char *prog; /* Program for postprocessing */
int uid;/* Owner of log */
int gid;/* Group of log */
int numlogs;/* Number of logs to keep */
@@ -106,11 +108,13 @@
 static void do_entry(struct conf_entry * ent);
 static void PRS(int argc, char **argv);
 static void usage(void);
-static void dotrim(char *log, const char *pid_file, int numdays, int falgs,
-   int perm, int owner_uid, int group_gid, int sig);
+static void dotrim(char *log, const char *pid_file, const char *prog,
+   int numdays, int falgs, int perm, int owner_uid,
+   int group_gid, int sig);
 static int log_trim(char *log);
 static void compress_log(char *log);
 static void bzcompress_log(char *log);
+static int post_prog(const char *prog, char *log, int owner_uid, int group_gid);
 static int sizefile(char *file);
 static int age_old_log(char *file);
 static pid_t get_pid(const char *pid_file);
@@ -119,6 +123,7 @@
int group_gid);
 static void createdir(char *dirpart);
 static time_t parseDWM(char *s);
+static int signame_to_signum(char *sig);
 
 int
 main(int argc, char **argv)
@@ -200,7 +205,7 @@
else
pid_file = NULL;
}
-   dotrim(ent->log, pid_file, ent->numlogs,
+   dotrim(ent->log, pid_file, ent->prog, ent->numlogs,
ent->flags, ent->permissions, ent->uid, ent->gid,
ent->sig);
} else {
@@ -460,34 +465,52 @@
if (q && *q) {
if (*q == '/')
working->pid_file = strdup(q);
-   else if (isdigit(*q))
+   else if (isalnum(*q))
goto got_sig;
-   else
-

Doubt of system(3)

2001-09-29 Thread Toshihiko ARAI

I consider the following code of system(3).  pid is changed by return
value of _wait4().  I feel this need a correction.

default:/* parent */
do {
pid = _wait4(pid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
break;

Please review and commit this patch.

Index: src/lib/libc/stdlib/system.c
===
RCS file: /home/ncvs/src/lib/libc/stdlib/system.c,v
retrieving revision 1.7
diff -u -r1.7 system.c
--- src/lib/libc/stdlib/system.c2001/01/24 13:00:59 1.7
+++ src/lib/libc/stdlib/system.c2001/09/29 08:53:14
@@ -86,9 +86,9 @@
execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
_exit(127);
default:/* parent */
-   do {
-   pid = _wait4(pid, &pstat, 0, (struct rusage *)0);
-   } while (pid == -1 && errno == EINTR);
+   while (_wait4(pid, &pstat, 0, (struct rusage *)0) == -1 &&
+  errno == EINTR)
+   ;   /* nothing */
break;
    }
    (void)_sigaction(SIGINT, &intact, NULL);
--
Toshihiko ARAI

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



4.2R CDROM from Walnut Creek CDROM?

2000-11-20 Thread Toshihiko ARAI

Hi,

In src/release/texts/*/RELNOTES.TXT for 4.2R, HEAD and
4-stable branches:

|FreeBSD 4.x-RELEASE and 3.x-RELEASE CDs may be ordered on CDROM from:
|
|Walnut Creek CDROM
|4041 Pike Lane, Suite D
|Concord CA  94520
|1-800-786-9907, +1-925-674-0783, +1-925-674-0821 (FAX)
|
|Or via the Internet from [EMAIL PROTECTED] or http://www.cdrom.com.
|Their current catalog can be obtained via ftp from:
|
|ftp://ftp.cdrom.com/cdrom/catalog

Correct needless?

--
Toshihiko ARAI / [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message