From 2c9777ad182dc312ad23e73347410a3fafd5b1d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Tue, 30 Oct 2012 14:15:19 +0000 Subject: [PATCH] allow setting of group owner for event files --- org.glite.lb.common/src/log_msg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.glite.lb.common/src/log_msg.c b/org.glite.lb.common/src/log_msg.c index d625517..508106e 100644 --- a/org.glite.lb.common/src/log_msg.c +++ b/org.glite.lb.common/src/log_msg.c @@ -27,6 +27,7 @@ limitations under the License. #include #include #include +#include #include "context-int.h" @@ -141,6 +142,7 @@ int edg_wll_log_event_write( int filedesc, i, filelock_status=-1; struct stat statbuf; + char *group_name; try_again: if ( (outfile = fopen(event_file, "a")) == NULL ) { @@ -193,6 +195,18 @@ try_again: goto cleanup; } + /* make the file writable for given group, if specified */ + if(NULL != (group_name = getenv("GLITE_GROUP"))) { + struct group *glite_group = getgrnam(group_name); + + if(NULL != glite_group) { + /* errors are ignored */ + fchown(filedesc, -1, glite_group->gr_gid); + fchmod(filedesc, 0660); + } + } + + if ( fseek(outfile, 0, SEEK_END) == -1 ) { edg_wll_SetError(ctx, errno, "fseek()"); goto cleanup; -- 1.8.2.3