From: Michal Voců Date: Tue, 30 Oct 2012 14:15:19 +0000 (+0000) Subject: allow setting of group owner for event files X-Git-Tag: glite-jobid-api-c_R_2_2_4_1~15 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=2c9777ad182dc312ad23e73347410a3fafd5b1d4;p=jra1mw.git allow setting of group owner for event files --- 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;