7019913 clock-applet's "time zone" can not list the choice last time osol_161
authorDavid Powell <david.e.powell@oracle.com>
Thu, 03 Mar 2011 14:39:37 -0800
changeset 670 e056d4dcc5fc
parent 669 19a64797000e
child 671 3b99d530b3bb
7019913 clock-applet's "time zone" can not list the choice last time
usr/src/cmd/rad/mod/rad_defaults.c
--- a/usr/src/cmd/rad/mod/rad_defaults.c	Thu Mar 03 13:50:32 2011 -0500
+++ b/usr/src/cmd/rad/mod/rad_defaults.c	Thu Mar 03 14:39:37 2011 -0800
@@ -20,10 +20,11 @@
  */
 
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,6 +32,8 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <unistd.h>
+#include <pwd.h>
+#include <grp.h>
 
 #include "rad_defaults.h"
 #include "rad_modapi.h"
@@ -212,7 +215,12 @@
 	}
 
 	(void) fclose(rfile);
-	if (fclose(wfile) != 0 || rename(wfname, fname) != 0) {
+
+	struct group *gsys = getgrnam("sys");
+	struct passwd *uroot = getpwnam("root");
+	if (fclose(wfile) != 0 || gsys == NULL || uroot == NULL ||
+	    chown(wfname, uroot->pw_uid, gsys->gr_gid) != 0 ||
+	    chmod(wfname, 0644) || rename(wfname, fname) != 0) {
 		error = errno;
 		(void) unlink(wfname);
 		return (error);