allow setting of group owner for event files
authorMichal Voců <michal@ruk.cuni.cz>
Tue, 30 Oct 2012 14:15:19 +0000 (14:15 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Tue, 30 Oct 2012 14:15:19 +0000 (14:15 +0000)
org.glite.lb.common/src/log_msg.c

index d625517..508106e 100644 (file)
@@ -27,6 +27,7 @@ limitations under the License.
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+#include <grp.h>
 
 #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;