libc: introduce <envvars.h>
The new header envvars.h contains the names of commonly used environment variables, such as $user, $ifs, $path and so on. These defines are useful for Jehanne core applications that use them to comunicate some values. They are not strictly required, but having such defines we can easily change the naming convention (from lowercase to uppercase).
This commit is contained in:
parent
65d37f432f
commit
fab9c1d80f
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Jehanne.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||||
|
*
|
||||||
|
* Jehanne is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 2 of the License.
|
||||||
|
*
|
||||||
|
* Jehanne is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file defines the names of a few environment variables shared
|
||||||
|
* among the userspace tools provided by Jehanne.
|
||||||
|
*
|
||||||
|
* It must not provide defines for variables used by commonly installed
|
||||||
|
* softwares, just the one used by the core tools, the one required
|
||||||
|
* to boot a minimal system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ENV_APID "apid"
|
||||||
|
#define ENV_USER "user"
|
||||||
|
#define ENV_HOME "home"
|
||||||
|
#define ENV_IFS "ifs"
|
||||||
|
#define ENV_PATH "path"
|
||||||
|
#define ENV_PID "pid"
|
||||||
|
#define ENV_PROMPT "prompt"
|
||||||
|
#define ENV_STATUS "status"
|
||||||
|
#define ENV_CDPATH "cdpath"
|
||||||
|
#define ENV_CPUTYPE "cputype"
|
||||||
|
#define ENV_SERVICE "service"
|
||||||
|
#define ENV_SYSNAME "sysname"
|
||||||
|
#define ENV_OBJTYPE "objtype"
|
||||||
|
|
||||||
|
#define ENV_WSYS "wsys"
|
||||||
|
|
||||||
|
extern char* jehanne_getenv(const char*);
|
||||||
|
extern int jehanne_putenv(const char*, const char*);
|
|
@ -325,7 +325,6 @@ extern int jehanne_encodefmt(Fmt*);
|
||||||
extern void jehanne_exits(const char*) __attribute__ ((noreturn));
|
extern void jehanne_exits(const char*) __attribute__ ((noreturn));
|
||||||
extern double jehanne_frexp(double, int*);
|
extern double jehanne_frexp(double, int*);
|
||||||
extern uintptr_t jehanne_getcallerpc(void);
|
extern uintptr_t jehanne_getcallerpc(void);
|
||||||
extern char* jehanne_getenv(const char*);
|
|
||||||
extern int jehanne_getfields(char*, char**, int, int, const char*);
|
extern int jehanne_getfields(char*, char**, int, int, const char*);
|
||||||
extern int jehanne_gettokens(char *, char **, int, const char *);
|
extern int jehanne_gettokens(char *, char **, int, const char *);
|
||||||
extern char* jehanne_getuser(void);
|
extern char* jehanne_getuser(void);
|
||||||
|
@ -344,7 +343,6 @@ extern void jehanne_perror(const char*);
|
||||||
extern int jehanne_pipe(int pipes[2]);
|
extern int jehanne_pipe(int pipes[2]);
|
||||||
extern int jehanne_postnote(int, int, const char *);
|
extern int jehanne_postnote(int, int, const char *);
|
||||||
extern double jehanne_pow10(int);
|
extern double jehanne_pow10(int);
|
||||||
extern int jehanne_putenv(const char*, const char*);
|
|
||||||
extern void jehanne_qsort(void*, long, int,
|
extern void jehanne_qsort(void*, long, int,
|
||||||
int (*)(const void*, const void*));
|
int (*)(const void*, const void*));
|
||||||
extern void* jehanne_bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
extern void* jehanne_bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
|
@ -124,9 +125,9 @@ threadmain(int argc, char *argv[])
|
||||||
fontnames[1] = estrdup(fontnames[1]);
|
fontnames[1] = estrdup(fontnames[1]);
|
||||||
|
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
cputype = getenv("cputype");
|
cputype = getenv(ENV_CPUTYPE);
|
||||||
objtype = getenv("objtype");
|
objtype = getenv(ENV_OBJTYPE);
|
||||||
home = getenv("home");
|
home = getenv(ENV_HOME);
|
||||||
p = getenv("tabstop");
|
p = getenv("tabstop");
|
||||||
if(p != nil){
|
if(p != nil){
|
||||||
maxtab = strtoul(p, nil, 0);
|
maxtab = strtoul(p, nil, 0);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
|
@ -61,7 +62,7 @@ threadmain(int argc, char *argv[])
|
||||||
av = emalloc(3*sizeof(char*));
|
av = emalloc(3*sizeof(char*));
|
||||||
av[0] = "rc";
|
av[0] = "rc";
|
||||||
av[1] = "-i";
|
av[1] = "-i";
|
||||||
name = getenv("sysname");
|
name = getenv(ENV_SYSNAME);
|
||||||
}else{
|
}else{
|
||||||
av = argv;
|
av = argv;
|
||||||
name = utfrrune(av[0], '/');
|
name = utfrrune(av[0], '/');
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
|
|
|
@ -63,7 +63,7 @@ runas(char *user, char *cmd)
|
||||||
{
|
{
|
||||||
if(becomeuser(user) < 0)
|
if(becomeuser(user) < 0)
|
||||||
sysfatal("can't change uid for %s: %r", user);
|
sysfatal("can't change uid for %s: %r", user);
|
||||||
putenv("service", "rx");
|
putenv(ENV_SERVICE, "rx");
|
||||||
execl("/bin/rc", "rc", "-lc", cmd, nil);
|
execl("/bin/rc", "rc", "-lc", cmd, nil);
|
||||||
sysfatal("exec /bin/rc: %r");
|
sysfatal("exec /bin/rc: %r");
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,7 +568,7 @@ rexec(User *user, Job *j)
|
||||||
open("/dev/null", OWRITE);
|
open("/dev/null", OWRITE);
|
||||||
|
|
||||||
if(strcmp(j->host, "local") == 0){
|
if(strcmp(j->host, "local") == 0){
|
||||||
putenv("service", "rx");
|
putenv(ENV_SERVICE, "rx");
|
||||||
execl("/bin/rc", "rc", "-lc", buf, nil);
|
execl("/bin/rc", "rc", "-lc", buf, nil);
|
||||||
} else {
|
} else {
|
||||||
execl("/bin/rx", "rx", j->host, buf, nil);
|
execl("/bin/rx", "rx", j->host, buf, nil);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <envvars.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
|
|
||||||
//static char secstore[100]; /* server name */ // NOT USED
|
//static char secstore[100]; /* server name */ // NOT USED
|
||||||
|
@ -712,7 +713,7 @@ promptforhostowner(void)
|
||||||
char owner[64], *p;
|
char owner[64], *p;
|
||||||
|
|
||||||
/* hack for bitsy; can't prompt during boot */
|
/* hack for bitsy; can't prompt during boot */
|
||||||
if(p = getenv("user")){
|
if(p = getenv(ENV_USER)){
|
||||||
writehostowner(p);
|
writehostowner(p);
|
||||||
free(p);
|
free(p);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <authsrv.h>
|
#include <authsrv.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
|
@ -70,10 +71,12 @@ void
|
||||||
setenv(char *var, char *val)
|
setenv(char *var, char *val)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
char buf[128+4];
|
||||||
|
|
||||||
fd = ocreate(var, OWRITE, 0644);
|
snprint(buf, sizeof(buf), "#e/%s", var);
|
||||||
|
fd = ocreate(buf, OWRITE, 0644);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
print("init: can't open %s\n", var);
|
print("init: can't open %s\n", buf);
|
||||||
else{
|
else{
|
||||||
fprint(fd, val);
|
fprint(fd, val);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -126,7 +129,7 @@ getauthdom(void)
|
||||||
if(authdom != nil)
|
if(authdom != nil)
|
||||||
return authdom;
|
return authdom;
|
||||||
|
|
||||||
sysname = getenv("sysname");
|
sysname = getenv(ENV_SYSNAME);
|
||||||
if(sysname == nil)
|
if(sysname == nil)
|
||||||
return strdup("cs.bell-labs.com");
|
return strdup("cs.bell-labs.com");
|
||||||
|
|
||||||
|
@ -209,7 +212,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
rfork(RFENVG|RFNAMEG);
|
rfork(RFENVG|RFNAMEG);
|
||||||
|
|
||||||
service = getenv("service");
|
service = getenv(ENV_SERVICE);
|
||||||
if(strcmp(service, "cpu") == 0)
|
if(strcmp(service, "cpu") == 0)
|
||||||
fprint(2, "login: warning: running on a cpu server!\n");
|
fprint(2, "login: warning: running on a cpu server!\n");
|
||||||
if(argc != 1){
|
if(argc != 1){
|
||||||
|
@ -239,24 +242,23 @@ main(int argc, char *argv[])
|
||||||
mountfactotum(srvname);
|
mountfactotum(srvname);
|
||||||
|
|
||||||
/* set up a new environment */
|
/* set up a new environment */
|
||||||
cputype = getenv("cputype");
|
cputype = getenv(ENV_CPUTYPE);
|
||||||
sysname = getenv("sysname");
|
sysname = getenv(ENV_SYSNAME);
|
||||||
tz = getenv("timezone");
|
tz = getenv("timezone");
|
||||||
rfork(RFCENVG);
|
rfork(RFCENVG);
|
||||||
setenv("#e/service", "con");
|
setenv(ENV_SERVICE, "con");
|
||||||
setenv("#e/user", user);
|
setenv(ENV_USER, user);
|
||||||
snprint(home, sizeof(home), "/usr/%s", user);
|
snprint(home, sizeof(home), "/usr/%s", user);
|
||||||
setenv("#e/home", home);
|
setenv(ENV_HOME, home);
|
||||||
setenv("#e/cputype", cputype);
|
setenv(ENV_CPUTYPE, cputype);
|
||||||
setenv("#e/objtype", cputype);
|
setenv(ENV_OBJTYPE, cputype);
|
||||||
if(sysname != nil)
|
if(sysname != nil)
|
||||||
setenv("#e/sysname", sysname);
|
setenv(ENV_SYSNAME, sysname);
|
||||||
if(tz != nil)
|
if(tz != nil)
|
||||||
setenv("#e/timezone", tz);
|
setenv("timezone", tz);
|
||||||
|
|
||||||
/* go to new home directory */
|
/* go to new home directory */
|
||||||
snprint(buf, sizeof(buf), "/usr/%s", user);
|
if(chdir(home) < 0)
|
||||||
if(chdir(buf) < 0)
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
/* read profile and start interactive rc */
|
/* read profile and start interactive rc */
|
||||||
|
|
|
@ -26,7 +26,7 @@ main(int argc, char *argv[])
|
||||||
if(argc)
|
if(argc)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
s = getenv("service");
|
s = getenv(ENV_SERVICE);
|
||||||
if(s && strcmp(s, "cpu") == 0){
|
if(s && strcmp(s, "cpu") == 0){
|
||||||
fprint(2, "netkey must not be run on the cpu server\n");
|
fprint(2, "netkey must not be run on the cpu server\n");
|
||||||
exits("boofhead");
|
exits("boofhead");
|
||||||
|
|
|
@ -25,7 +25,7 @@ main(int argc, char **argv)
|
||||||
syslog(0, "secstore", "no /lib/ndb/local");
|
syslog(0, "secstore", "no /lib/ndb/local");
|
||||||
db = ndbcat(db, db2);
|
db = ndbcat(db, db2);
|
||||||
|
|
||||||
print("user=%s\n", getenv("user"));
|
print("%s=%s\n", ENV_USER, getenv(ENV_USER));
|
||||||
print("%s\n", secureidcheck(getenv("user"), argv[1]));
|
print("%s\n", secureidcheck(getenv(ENV_USER), argv[1]));
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ THIS SOFTWARE.
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "awk.h"
|
#include "awk.h"
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
|
@ -301,7 +302,7 @@ remoteside(int old)
|
||||||
int i, n, fd, badchdir, gotcmd;
|
int i, n, fd, badchdir, gotcmd;
|
||||||
|
|
||||||
rfork(RFENVG);
|
rfork(RFENVG);
|
||||||
putenv("service", "cpu");
|
putenv(ENV_SERVICE, "cpu");
|
||||||
fd = 0;
|
fd = 0;
|
||||||
|
|
||||||
/* negotiate authentication mechanism */
|
/* negotiate authentication mechanism */
|
||||||
|
@ -319,9 +320,9 @@ remoteside(int old)
|
||||||
fatal(1, "srvauth");
|
fatal(1, "srvauth");
|
||||||
|
|
||||||
/* Set environment values for the user */
|
/* Set environment values for the user */
|
||||||
putenv("user", user);
|
putenv(ENV_USER, user);
|
||||||
sprint(home, "/usr/%s", user);
|
sprint(home, "/usr/%s", user);
|
||||||
putenv("home", home);
|
putenv(ENV_HOME, home);
|
||||||
|
|
||||||
/* Now collect invoking cpu's current directory or possibly a command */
|
/* Now collect invoking cpu's current directory or possibly a command */
|
||||||
gotcmd = 0;
|
gotcmd = 0;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <disk.h>
|
#include <disk.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
|
@ -115,7 +116,7 @@ main(int argc, char **argv)
|
||||||
zbuf = malloc(buflen);
|
zbuf = malloc(buflen);
|
||||||
memset(zbuf, 0, buflen);
|
memset(zbuf, 0, buflen);
|
||||||
|
|
||||||
cputype = getenv("cputype");
|
cputype = getenv(ENV_CPUTYPE);
|
||||||
if(cputype == 0)
|
if(cputype == 0)
|
||||||
cputype = "386";
|
cputype = "386";
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
#include <libsec.h>
|
#include <libsec.h>
|
||||||
|
@ -213,7 +214,7 @@ main(int argc, char **argv)
|
||||||
fatal("exportfs by none disallowed");
|
fatal("exportfs by none disallowed");
|
||||||
if(auth_chuid(ai, nsfile) < 0)
|
if(auth_chuid(ai, nsfile) < 0)
|
||||||
fatal("auth_chuid: %r");
|
fatal("auth_chuid: %r");
|
||||||
putenv("service", "exportfs");
|
putenv(ENV_SERVICE, "exportfs");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(srvfdfile){
|
if(srvfdfile){
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
|
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <libsec.h>
|
#include <libsec.h>
|
||||||
|
|
||||||
|
@ -363,7 +364,7 @@ passive(void)
|
||||||
sysfatal("auth_proxy: %r");
|
sysfatal("auth_proxy: %r");
|
||||||
if(auth_chuid(ai, nil) < 0)
|
if(auth_chuid(ai, nil) < 0)
|
||||||
sysfatal("auth_chuid: %r");
|
sysfatal("auth_chuid: %r");
|
||||||
putenv("service", "import");
|
putenv(ENV_SERVICE, "import");
|
||||||
|
|
||||||
fd = dup(0, -1);
|
fd = dup(0, -1);
|
||||||
close(0);
|
close(0);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include "dhcp.h"
|
#include "dhcp.h"
|
||||||
|
|
||||||
|
@ -210,6 +211,7 @@ void
|
||||||
dhcpinit(void)
|
dhcpinit(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
char *sysname;
|
||||||
|
|
||||||
dhcp.state = Sinit;
|
dhcp.state = Sinit;
|
||||||
dhcp.timeout = 4;
|
dhcp.timeout = 4;
|
||||||
|
@ -222,7 +224,9 @@ dhcpinit(void)
|
||||||
dhcp.xid = time(0)*getpid();
|
dhcp.xid = time(0)*getpid();
|
||||||
srand(dhcp.xid);
|
srand(dhcp.xid);
|
||||||
|
|
||||||
sprint(dhcp.cid, "%s.%d", getenv("sysname"), getpid());
|
sysname = getenv(ENV_SYSNAME);
|
||||||
|
sprint(dhcp.cid, "%s.%d", sysname, getpid());
|
||||||
|
free(sysname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
|
@ -1360,7 +1361,7 @@ readsysname(void)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = getenv("sysname");
|
p = getenv(ENV_SYSNAME);
|
||||||
if(p == nil || *p == 0)
|
if(p == nil || *p == 0)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
|
@ -390,7 +391,7 @@ init(void)
|
||||||
nsec(); /* make sure time file is open before forking */
|
nsec(); /* make sure time file is open before forking */
|
||||||
|
|
||||||
setnetmtpt(conf.mpoint, sizeof conf.mpoint, nil);
|
setnetmtpt(conf.mpoint, sizeof conf.mpoint, nil);
|
||||||
conf.cputype = getenv("cputype");
|
conf.cputype = getenv(ENV_CPUTYPE);
|
||||||
if(conf.cputype == nil)
|
if(conf.cputype == nil)
|
||||||
conf.cputype = "386";
|
conf.cputype = "386";
|
||||||
|
|
||||||
|
@ -410,7 +411,7 @@ parseargs(int argc, char **argv)
|
||||||
|
|
||||||
/* default to any host name we already have */
|
/* default to any host name we already have */
|
||||||
if(*conf.hostname == 0){
|
if(*conf.hostname == 0){
|
||||||
p = getenv("sysname");
|
p = getenv(ENV_SYSNAME);
|
||||||
if(p == nil || *p == 0)
|
if(p == nil || *p == 0)
|
||||||
p = sysname();
|
p = sysname();
|
||||||
if(p != nil)
|
if(p != nil)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
|
|
||||||
#define NAMELEN 64 /* reasonable upper limit for name elements */
|
#define NAMELEN 64 /* reasonable upper limit for name elements */
|
||||||
|
@ -97,7 +98,7 @@ main(int argc, char *argv[])
|
||||||
quiet = 0;
|
quiet = 0;
|
||||||
immutable = 0;
|
immutable = 0;
|
||||||
argv0 = argv[0];
|
argv0 = argv[0];
|
||||||
cpu = getenv("cputype");
|
cpu = getenv(ENV_CPUTYPE);
|
||||||
if(cpu == 0)
|
if(cpu == 0)
|
||||||
error("can't get cputype");
|
error("can't get cputype");
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include <mp.h>
|
#include <mp.h>
|
||||||
|
@ -249,7 +250,7 @@ main(int argc, char **argv)
|
||||||
fmtinstall('E', eipfmt);
|
fmtinstall('E', eipfmt);
|
||||||
fmtinstall('I', eipfmt);
|
fmtinstall('I', eipfmt);
|
||||||
fmtinstall('V', eipfmt);
|
fmtinstall('V', eipfmt);
|
||||||
sysid = getenv("sysname");
|
sysid = getenv(ENV_SYSNAME);
|
||||||
|
|
||||||
/* detach from the current namespace */
|
/* detach from the current namespace */
|
||||||
if(debug)
|
if(debug)
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
* -t suppresses expanding multiple blanks into tabs
|
* -t suppresses expanding multiple blanks into tabs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
#include <draw.h>
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <draw.h>
|
||||||
|
#include <bio.h>
|
||||||
|
|
||||||
#define WIDTH 80
|
#define WIDTH 80
|
||||||
#define TAB 4
|
#define TAB 4
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
|
@ -1032,7 +1033,7 @@ ipid(void)
|
||||||
* is the ip address. ignore that.
|
* is the ip address. ignore that.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
p = getenv("sysname");
|
p = getenv(ENV_SYSNAME);
|
||||||
if(p && *p){
|
if(p && *p){
|
||||||
attr = ipattr(p);
|
attr = ipattr(p);
|
||||||
if(strcmp(attr, "ip") != 0)
|
if(strcmp(attr, "ip") != 0)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* RFC2136 DNS inform - necessary for Win2k3 DNS servers */
|
/* RFC2136 DNS inform - necessary for Win2k3 DNS servers */
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
|
@ -123,8 +124,8 @@ main(int argc, char *argv[])
|
||||||
if(argc != 0)
|
if(argc != 0)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if((sysname = getenv("sysname")) == nil)
|
if((sysname = getenv(ENV_SYSNAME)) == nil)
|
||||||
sysfatal("$sysname not set");
|
sysfatal("$%s not set", ENV_SYSNAME);
|
||||||
|
|
||||||
if((db = ndbopen(nil)) == nil)
|
if((db = ndbopen(nil)) == nil)
|
||||||
sysfatal("can't open ndb: %r");
|
sysfatal("can't open ndb: %r");
|
||||||
|
|
|
@ -8,16 +8,9 @@
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
|
|
||||||
#define ENV_RCARGLIST "*"
|
#define ENV_RCARGLIST "*"
|
||||||
#define ENV_APID "apid"
|
|
||||||
#define ENV_HOME "home"
|
|
||||||
#define ENV_IFS "ifs"
|
|
||||||
#define ENV_PATH "path"
|
|
||||||
#define ENV_PID "pid"
|
|
||||||
#define ENV_PROMPT "prompt"
|
|
||||||
#define ENV_STATUS "status"
|
|
||||||
#define ENV_CDPATH "cdpath"
|
|
||||||
#define ENV_RCNAME "rcname"
|
#define ENV_RCNAME "rcname"
|
||||||
#define ENV_RCCMD "rccmd"
|
#define ENV_RCCMD "rccmd"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
|
@ -167,7 +168,7 @@ filsysinit(Channel *cxfidalloc)
|
||||||
* Post srv pipe
|
* Post srv pipe
|
||||||
*/
|
*/
|
||||||
snprint(srvpipe, sizeof(srvpipe), "/srv/rio.%s.%d", fs->user, pid);
|
snprint(srvpipe, sizeof(srvpipe), "/srv/rio.%s.%d", fs->user, pid);
|
||||||
post(srvpipe, "wsys", fs->cfd);
|
post(srvpipe, ENV_WSYS, fs->cfd);
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
|
@ -172,7 +173,7 @@ threadmain(int argc, char *argv[])
|
||||||
maxtab = 4;
|
maxtab = 4;
|
||||||
free(s);
|
free(s);
|
||||||
|
|
||||||
s = getenv("cputype");
|
s = getenv(ENV_CPUTYPE);
|
||||||
if(s){
|
if(s){
|
||||||
snprint(buf, sizeof(buf), "/arch/%s/aux/rio", s);
|
snprint(buf, sizeof(buf), "/arch/%s/aux/rio", s);
|
||||||
bind(buf, "/cmd", MBEFORE);
|
bind(buf, "/cmd", MBEFORE);
|
||||||
|
|
|
@ -26,7 +26,6 @@ Rune *right[]= {
|
||||||
|
|
||||||
char RSAM[] = "sam";
|
char RSAM[] = "sam";
|
||||||
char SAMTERM[] = "/cmd/aux/samterm";
|
char SAMTERM[] = "/cmd/aux/samterm";
|
||||||
char HOME[] = "home";
|
|
||||||
char TMPDIR[] = "/tmp";
|
char TMPDIR[] = "/tmp";
|
||||||
char SH[] = "rc";
|
char SH[] = "rc";
|
||||||
char SHPATH[] = "/cmd/rc";
|
char SHPATH[] = "/cmd/rc";
|
||||||
|
|
|
@ -83,7 +83,7 @@ void main(int argc, char *argv[])
|
||||||
Strinit0(&rhs);
|
Strinit0(&rhs);
|
||||||
Strinit0(&curwd);
|
Strinit0(&curwd);
|
||||||
Strinit0(&plan9cmd);
|
Strinit0(&plan9cmd);
|
||||||
home = getenv(HOME);
|
home = getenv(ENV_HOME);
|
||||||
disk = diskinit();
|
disk = diskinit();
|
||||||
if(home == 0)
|
if(home == 0)
|
||||||
home = "/";
|
home = "/";
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <plumb.h>
|
#include <plumb.h>
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
|
@ -353,7 +354,6 @@ extern Rune *right[];
|
||||||
|
|
||||||
extern char RSAM[]; /* system dependent */
|
extern char RSAM[]; /* system dependent */
|
||||||
extern char SAMTERM[];
|
extern char SAMTERM[];
|
||||||
extern char HOME[];
|
|
||||||
extern char TMPDIR[];
|
extern char TMPDIR[];
|
||||||
extern char SH[];
|
extern char SH[];
|
||||||
extern char SHPATH[];
|
extern char SHPATH[];
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <mouse.h>
|
#include <mouse.h>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
|
@ -1236,7 +1237,7 @@ main(int argc, char *argv[])
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
|
|
||||||
nmach = 1;
|
nmach = 1;
|
||||||
mysysname = getenv("sysname");
|
mysysname = getenv(ENV_SYSNAME);
|
||||||
if(mysysname == nil){
|
if(mysysname == nil){
|
||||||
fprint(2, "stats: can't find $sysname: %r\n");
|
fprint(2, "stats: can't find $sysname: %r\n");
|
||||||
exits("sysname");
|
exits("sysname");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
#include "ureg.h"
|
#include "ureg.h"
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
|
#include "envvars.h"
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "apic.h"
|
#include "apic.h"
|
||||||
|
@ -374,11 +375,11 @@ init0(void)
|
||||||
jehanne_snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile);
|
jehanne_snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile);
|
||||||
loadenv(oargc, oargv);
|
loadenv(oargc, oargv);
|
||||||
ksetenv("terminal", buf, 0);
|
ksetenv("terminal", buf, 0);
|
||||||
ksetenv("cputype", "amd64", 0);
|
ksetenv(ENV_CPUTYPE, "amd64", 0);
|
||||||
if(cpuserver)
|
if(cpuserver)
|
||||||
ksetenv("service", "cpu", 0);
|
ksetenv(ENV_SERVICE, "cpu", 0);
|
||||||
else
|
else
|
||||||
ksetenv("service", "terminal", 0);
|
ksetenv(ENV_SERVICE, "terminal", 0);
|
||||||
poperror();
|
poperror();
|
||||||
}
|
}
|
||||||
kproc("alarm", alarmkproc, 0);
|
kproc("alarm", alarmkproc, 0);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
#include "../boot/boot.h"
|
#include "../boot/boot.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
#include "../boot/boot.h"
|
#include "../boot/boot.h"
|
||||||
|
@ -22,7 +23,7 @@ authentication(int cpuflag)
|
||||||
char *argv[16], **av;
|
char *argv[16], **av;
|
||||||
int ac;
|
int ac;
|
||||||
|
|
||||||
if(jehanne_access(factotumPath, AEXEC) < 0 || jehanne_getenv("user") != nil){
|
if(jehanne_access(factotumPath, AEXEC) < 0 || jehanne_getenv(ENV_USER) != nil){
|
||||||
glenda();
|
glenda();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ glenda(void)
|
||||||
int fd;
|
int fd;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = jehanne_getenv("user");
|
s = jehanne_getenv(ENV_USER);
|
||||||
if(s == nil)
|
if(s == nil)
|
||||||
s = "glenda";
|
s = "glenda";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <authsrv.h>
|
#include <authsrv.h>
|
||||||
|
@ -65,9 +66,9 @@ buildns(int newns, char *user, char *file)
|
||||||
}
|
}
|
||||||
if(newns){
|
if(newns){
|
||||||
rfork(RFENVG|RFCNAMEG);
|
rfork(RFENVG|RFCNAMEG);
|
||||||
setenv("user", user);
|
setenv(ENV_USER, user);
|
||||||
snprint(home, sizeof home, "/usr/%s", user);
|
snprint(home, sizeof home, "/usr/%s", user);
|
||||||
setenv("home", home);
|
setenv(ENV_HOME, home);
|
||||||
}
|
}
|
||||||
|
|
||||||
cdroot = nsfile(newns ? "newns" : "addns", b, rpc);
|
cdroot = nsfile(newns ? "newns" : "addns", b, rpc);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <authsrv.h>
|
#include <authsrv.h>
|
||||||
|
|
||||||
static int32_t finddosfile(int, char*);
|
static int32_t finddosfile(int, char*);
|
||||||
|
@ -137,7 +138,7 @@ findnvram(Nvrwhere *locp)
|
||||||
if (nvrfile == nil)
|
if (nvrfile == nil)
|
||||||
nvrfile = getenv("nvram");
|
nvrfile = getenv("nvram");
|
||||||
if (cputype == nil)
|
if (cputype == nil)
|
||||||
cputype = getenv("cputype");
|
cputype = getenv(ENV_CPUTYPE);
|
||||||
if(cputype == nil)
|
if(cputype == nil)
|
||||||
cputype = strdup("mips");
|
cputype = strdup("mips");
|
||||||
if(strcmp(cputype, "386")==0 || strcmp(cputype, "amd64")==0 || strcmp(cputype, "alpha")==0) {
|
if(strcmp(cputype, "386")==0 || strcmp(cputype, "amd64")==0 || strcmp(cputype, "alpha")==0) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <9P2000.h>
|
#include <9P2000.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
|
|
||||||
/* Connect us to new window, if possible */
|
/* Connect us to new window, if possible */
|
||||||
|
@ -19,7 +20,7 @@ newwindow(char *str)
|
||||||
char *wsys;
|
char *wsys;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
wsys = getenv("wsys");
|
wsys = getenv(ENV_WSYS);
|
||||||
if(wsys == nil)
|
if(wsys == nil)
|
||||||
return -1;
|
return -1;
|
||||||
fd = open(wsys, ORDWR);
|
fd = open(wsys, ORDWR);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <ndb.h>
|
#include <ndb.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include "plumb.h"
|
#include "plumb.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <lib9.h>
|
#include <lib9.h>
|
||||||
|
#include <envvars.h>
|
||||||
#include <posix.h>
|
#include <posix.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue