Print this page
4337 eliminate /etc/TIMEZONE


2196         (void) memcpy(&envinit[basicenv], newenv, sizeof (newenv));
2197 
2198         /* Set up environment */
2199         if (rflag) {
2200                 ENVSTRNCAT(term, terminal);
2201         } else if (hflag) {
2202                 if (strlen(terminal)) {
2203                         ENVSTRNCAT(term, terminal);
2204                 }
2205         } else {
2206                 char *tp = getenv("TERM");
2207 
2208                 if ((tp != NULL) && (*tp != '\0'))
2209                         ENVSTRNCAT(term, tp);
2210         }
2211 
2212         ENVSTRNCAT(logname, pwd->pw_name);
2213 
2214         /*
2215          * There are three places to get timezone info.  init.c sets
2216          * TZ if the file /etc/TIMEZONE contains a value for TZ.
2217          * login.c looks in the file /etc/default/login for a
2218          * variable called TIMEZONE being set.  If TIMEZONE has a
2219          *  value, TZ is set to that value; no environment variable
2220          * TIMEZONE is set, only TZ.  If neither of these methods
2221          * work to set TZ, then the library routines  will default
2222          * to using the file /usr/lib/locale/TZ/localtime.
2223          *
2224          * There is a priority set up here.  If /etc/TIMEZONE has
2225          * a value for TZ, that value remains top priority.  If the
2226          * file /etc/default/login has TIMEZONE set, that has second
2227          * highest priority not overriding the value of TZ in
2228          * /etc/TIMEZONE.  The reason for this priority is that the
2229          * file /etc/TIMEZONE is supposed to be sourced by
2230          * /etc/profile.  We are doing the "sourcing" prematurely in
2231          * init.c.  Additionally, a login C shell doesn't source the
2232          * file /etc/profile thus not sourcing /etc/TIMEZONE thus not
2233          * allowing an adminstrator to globally set TZ for all users
2234          */
2235         if (Def_tz != NULL)     /* Is there a TZ from defaults/login? */
2236                 tmp_tz = Def_tz;
2237 
2238         if ((Def_tz = getenv("TZ")) != NULL) {
2239                 ENVSTRNCAT(timez, Def_tz);
2240         } else if (tmp_tz != NULL) {
2241                 Def_tz = tmp_tz;
2242                 ENVSTRNCAT(timez, Def_tz);
2243         }
2244 
2245         if (Def_hertz == NULL)
2246                 (void) sprintf(hertz + strlen(hertz), "%lu", HZ);
2247         else
2248                 ENVSTRNCAT(hertz, Def_hertz);
2249 
2250         if (Def_path == NULL)
2251                 (void) strlcat(path, DEF_PATH, sizeof (path));
2252         else




2196         (void) memcpy(&envinit[basicenv], newenv, sizeof (newenv));
2197 
2198         /* Set up environment */
2199         if (rflag) {
2200                 ENVSTRNCAT(term, terminal);
2201         } else if (hflag) {
2202                 if (strlen(terminal)) {
2203                         ENVSTRNCAT(term, terminal);
2204                 }
2205         } else {
2206                 char *tp = getenv("TERM");
2207 
2208                 if ((tp != NULL) && (*tp != '\0'))
2209                         ENVSTRNCAT(term, tp);
2210         }
2211 
2212         ENVSTRNCAT(logname, pwd->pw_name);
2213 
2214         /*
2215          * There are three places to get timezone info.  init.c sets
2216          * TZ if the file /etc/default/init contains a value for TZ.
2217          * login.c looks in the file /etc/default/login for a
2218          * variable called TIMEZONE being set.  If TIMEZONE has a
2219          *  value, TZ is set to that value; no environment variable
2220          * TIMEZONE is set, only TZ.  If neither of these methods
2221          * work to set TZ, then the library routines  will default
2222          * to using the file /usr/lib/locale/TZ/localtime.
2223          *
2224          * There is a priority set up here.  If /etc/default/init has
2225          * a value for TZ, that value remains top priority.  If the
2226          * file /etc/default/login has TIMEZONE set, that has second
2227          * highest priority not overriding the value of TZ in
2228          * /etc/default/init.  The reason for this priority is that the
2229          * file /etc/default/init is supposed to be sourced by
2230          * /etc/profile.  We are doing the "sourcing" prematurely in
2231          * init.c.  Additionally, a login C shell doesn't source the
2232          * file /etc/profile thus not sourcing /etc/default/init thus not
2233          * allowing an adminstrator to globally set TZ for all users
2234          */
2235         if (Def_tz != NULL)     /* Is there a TZ from defaults/login? */
2236                 tmp_tz = Def_tz;
2237 
2238         if ((Def_tz = getenv("TZ")) != NULL) {
2239                 ENVSTRNCAT(timez, Def_tz);
2240         } else if (tmp_tz != NULL) {
2241                 Def_tz = tmp_tz;
2242                 ENVSTRNCAT(timez, Def_tz);
2243         }
2244 
2245         if (Def_hertz == NULL)
2246                 (void) sprintf(hertz + strlen(hertz), "%lu", HZ);
2247         else
2248                 ENVSTRNCAT(hertz, Def_hertz);
2249 
2250         if (Def_path == NULL)
2251                 (void) strlcat(path, DEF_PATH, sizeof (path));
2252         else