summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-18 02:14:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-18 02:14:46 +0000
commite3af82154285e1dab113acac4d00f3a8cb0c72ed (patch)
tree2e8d93d4f96f982cb362fe396c818c301fa840b3
parentec9a81256ab16206fb394fad8552c4e1c3cf2e62 (diff)
more indent
-rw-r--r--usr.sbin/amd/amd/info_file.c48
-rw-r--r--usr.sbin/amd/amd/info_hes.c65
-rw-r--r--usr.sbin/amd/amd/info_ndbm.c13
-rw-r--r--usr.sbin/amd/amd/info_nis.c34
-rw-r--r--usr.sbin/amd/amd/info_passwd.c24
-rw-r--r--usr.sbin/amd/amd/info_union.c34
6 files changed, 141 insertions, 77 deletions
diff --git a/usr.sbin/amd/amd/info_file.c b/usr.sbin/amd/amd/info_file.c
index 431e9f8103d..1e9b1fffad1 100644
--- a/usr.sbin/amd/amd/info_file.c
+++ b/usr.sbin/amd/amd/info_file.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_file.c 8.1 (Berkeley) 6/6/93
- * $Id: info_file.c,v 1.2 2002/07/18 00:50:23 pvalchev Exp $
+ * $Id: info_file.c,v 1.3 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -51,17 +51,20 @@
#define MAX_LINE_LEN 2048
-static int read_line(char *buf, int size, FILE *fp)
+static int
+read_line(char *buf, int size, FILE *fp)
{
int done = 0;
do {
while (fgets(buf, size, fp)) {
int len = strlen(buf);
+
done += len;
if (len > 1 && buf[len-2] == '\\' &&
- buf[len-1] == '\n') {
+ buf[len-1] == '\n') {
int ch;
+
buf += len - 2;
size -= len - 2;
*buf = '\n'; buf[1] = '\0';
@@ -69,22 +72,23 @@ static int read_line(char *buf, int size, FILE *fp)
* Skip leading white space on next line
*/
while ((ch = getc(fp)) != EOF &&
- isascii(ch) && isspace(ch))
- ;
+ isascii(ch) && isspace(ch))
+ ;
(void) ungetc(ch, fp);
} else {
return done;
}
}
} while (size > 0 && !feof(fp));
-
return done;
}
/*
* Try to locate a key in a file
*/
-static int search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt_map *m, void (*fn)(mnt_map *m, char*, char*))
+static int
+search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt_map *m,
+ void (*fn)(mnt_map *m, char*, char*))
{
char key_val[MAX_LINE_LEN];
int chuck = 0;
@@ -95,13 +99,15 @@ static int search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt
char *cp;
char *hash;
int len = strlen(key_val);
+
line_no++;
/*
* Make sure we got the whole line
*/
if (key_val[len-1] != '\n') {
- plog(XLOG_WARNING, "line %d in \"%s\" is too long", line_no, map);
+ plog(XLOG_WARNING, "line %d in \"%s\" is too long",
+ line_no, map);
chuck = 1;
} else {
key_val[len-1] = '\0';
@@ -157,7 +163,8 @@ static int search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt
if (!fn)
return 0;
} else {
- plog(XLOG_USER, "%s: line %d has no value field", map, line_no);
+ plog(XLOG_USER, "%s: line %d has no value field",
+ map, line_no);
}
}
@@ -168,7 +175,7 @@ again:
*/
if (chuck) {
while (fgets(key_val, sizeof(key_val), fp) &&
- !strchr(key_val, '\n'))
+ !strchr(key_val, '\n'))
;
chuck = 0;
}
@@ -177,11 +184,14 @@ again:
return fn ? 0 : ENOENT;
}
-static FILE *file_open(char *map, time_t *tp)
+static FILE *
+file_open(char *map, time_t *tp)
{
FILE *mapf = fopen(map, "r");
+
if (mapf && tp) {
struct stat stb;
+
if (fstat(fileno(mapf), &stb) < 0)
*tp = clocktime();
else
@@ -190,9 +200,11 @@ static FILE *file_open(char *map, time_t *tp)
return mapf;
}
-int file_init(char *map, time_t *tp)
+int
+file_init(char *map, time_t *tp)
{
FILE *mapf = file_open(map, tp);
+
if (mapf) {
(void) fclose(mapf);
return 0;
@@ -200,9 +212,11 @@ int file_init(char *map, time_t *tp)
return errno;
}
-int file_reload(mnt_map *m, char *map, void (*fn)())
+int
+file_reload(mnt_map *m, char *map, void (*fn)())
{
FILE *mapf = file_open(map, (time_t *) 0);
+
if (mapf) {
int error = search_or_reload_file(mapf, map, 0, 0, m, fn);
(void) fclose(mapf);
@@ -212,10 +226,12 @@ int file_reload(mnt_map *m, char *map, void (*fn)())
return errno;
}
-int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
+int
+file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
{
time_t t;
FILE *mapf = file_open(map, &t);
+
if (mapf) {
int error;
if (*tp < t) {
@@ -231,9 +247,11 @@ int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
return errno;
}
-int file_mtime(char *map, time_t *tp)
+int
+file_mtime(char *map, time_t *tp)
{
FILE *mapf = file_open(map, tp);
+
if (mapf) {
(void) fclose(mapf);
return 0;
diff --git a/usr.sbin/amd/amd/info_hes.c b/usr.sbin/amd/amd/info_hes.c
index e90e3658c0a..86e4b93ab12 100644
--- a/usr.sbin/amd/amd/info_hes.c
+++ b/usr.sbin/amd/amd/info_hes.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_hes.c 8.1 (Berkeley) 6/6/93
- * $Id: info_hes.c,v 1.9 2002/07/18 02:03:00 deraadt Exp $
+ * $Id: info_hes.c,v 1.10 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -77,7 +77,8 @@ static int servernum;
/*
* No easy way to probe the server - check the map name begins with "hesiod."
*/
-int hesiod_init(char *map, time_t *tp)
+int
+hesiod_init(char *map, time_t *tp)
{
#ifdef DEBUG
dlog("hesiod_init(%s)", map);
@@ -95,20 +96,24 @@ int hesiod_init(char *map, time_t *tp)
* call to hes_resolve("/defaults", "home.automount");
*/
#ifdef notdef
-#define MAKE_HES_NAME(dest, src) snprintf(dest, sizeof(dest), "%s%s", src + HES_PREFLEN, ".automount")
+#define MAKE_HES_NAME(dest, src) snprintf(dest, sizeof(dest), \
+ "%s%s", src + HES_PREFLEN, ".automount")
#endif
/*
* Do a Hesiod nameserver call.
* Modify time is ignored by Hesiod - XXX
*/
-int hesiod_search(mnt_map *m, char *map, char **pval, time_t *tp)
+int
+hesiod_search(mnt_map *m, char *map, char **pval, time_t *tp)
{
int error;
char hes_key[MAXPATHLEN];
char **rvec;
+
#ifdef DEBUG
- dlog("hesiod_search(m=%x, map=%s, key=%s, pval=%x tp=%x)", m, map, key, pval, tp);
+ dlog("hesiod_search(m=%x, map=%s, key=%s, pval=%x tp=%x)",
+ m, map, key, pval, tp);
#endif
/*MAKE_HES_NAME(hes_map, map);*/
snprintf(hes_key, sizeof(hes_key), "%s.%s", key, map+HES_PREFLEN);
@@ -166,7 +171,8 @@ static mnt_map *hs_map;
static int hs_nscount;
static char nsaddr_list[MAX_NSADDR][sizeof(struct in_addr)];
-int hesiod_reload(mnt_map *m, char *map, void (*fn)())
+int
+hesiod_reload(mnt_map *m, char *map, void (*fn)())
{
char *zone_name, *cp;
short domainlen;
@@ -209,6 +215,7 @@ int hesiod_reload(mnt_map *m, char *map, void (*fn)())
return(-1);
}
+int
hs_zone_transfer(char *domain)
{
int status, len;
@@ -220,7 +227,7 @@ hs_zone_transfer(char *domain)
dlog("hs_zone_transfer (%s)", domain);
#endif
if ((len = res_mkquery(QUERY, domain, C_HS, T_AXFR,
- (char *)NULL, 0, NULL, buf, PACKETSZ)) == -1) {
+ (char *)NULL, 0, NULL, buf, PACKETSZ)) == -1) {
#ifdef DEBUG
dlog("hs_zone_transfer: res_mkquery failed");
#endif
@@ -240,6 +247,7 @@ hs_zone_transfer(char *domain)
#define hs_server_addr(ns) ((struct in_addr *) nsaddr_list[ns])
+int
hs_res_send(char *buf, int buflen, char *answer, int anslen)
{
int retry, ns;
@@ -270,7 +278,7 @@ hs_res_send(char *buf, int buflen, char *answer, int anslen)
}
servernum = ns;
bcopy(hs_server_addr(ns), &server.sin_addr,
- sizeof(struct in_addr));
+ sizeof(struct in_addr));
server.sin_family = AF_INET;
server.sin_port = htons(NAMESERVER_PORT);
@@ -297,7 +305,7 @@ hs_res_send(char *buf, int buflen, char *answer, int anslen)
status = 0;
while (s != -1 && soacnt < 2 && status != -2) {
if ((status =
- hs_readresp(s, answer, anslen)) == -1) {
+ hs_readresp(s, answer, anslen)) == -1) {
(void) close(s);
s = -1;
continue;
@@ -327,6 +335,7 @@ hs_res_send(char *buf, int buflen, char *answer, int anslen)
-1: Error
-2: Permanent failure
*/
+int
hs_readresp(int s, char *answer, int anslen)
{
register int len, n;
@@ -335,7 +344,7 @@ hs_readresp(int s, char *answer, int anslen)
cp = answer;
len = sizeof(short);
while (len != 0 &&
- (n = hs_res_vcread(s, (char *)cp, (int)len, &hs_timeout)) > 0) {
+ (n = hs_res_vcread(s, (char *)cp, (int)len, &hs_timeout)) > 0) {
cp += n;
len -= n;
}
@@ -349,7 +358,7 @@ hs_readresp(int s, char *answer, int anslen)
return(-1);
}
while (len != 0 &&
- (n = hs_res_vcread(s, (char *)cp, (int)len, &hs_timeout)) > 0) {
+ (n = hs_res_vcread(s, (char *)cp, (int)len, &hs_timeout)) > 0) {
cp += n;
len -= n;
}
@@ -358,6 +367,7 @@ hs_readresp(int s, char *answer, int anslen)
return(hs_parse(answer, answer+PACKETSZ));
}
+int
hs_res_vcread(int sock, char *buf, int buflen, struct timeval *timeout)
{
register int n;
@@ -368,6 +378,7 @@ hs_res_vcread(int sock, char *buf, int buflen, struct timeval *timeout)
return(n);
}
+int
hs_res_selwait(int sock, struct timeval timeout)
{
fd_set *fdsp;
@@ -383,8 +394,7 @@ hs_res_selwait(int sock, struct timeval timeout)
memset(fdsp, 0, fdsn);
FD_SET(sock, fdsp);
- n = select(sock+1, fdsp, (fd_set *)NULL,
- (fd_set *)NULL, timeout);
+ n = select(sock+1, fdsp, NULL, NULL, timeout);
free(fdsp);
return(n);
}
@@ -394,6 +404,7 @@ hs_res_selwait(int sock, struct timeval timeout)
-1: Error
-2: Permanent failure
*/
+int
hs_parse(char *msg, char *eom)
{
register char *cp;
@@ -408,7 +419,9 @@ hs_parse(char *msg, char *eom)
if (hp->rcode != NOERROR || hp->opcode != QUERY) {
char dq[20];
#ifdef DEBUG
- dlog("Bad response (%d) from nameserver %s", hp->rcode, inet_dquad(dq, sizeof(dq), hs_server_addr(servernum)->s_addr));
+ dlog("Bad response (%d) from nameserver %s",
+ hp->rcode, inet_dquad(dq, sizeof(dq),
+ hs_server_addr(servernum)->s_addr));
#endif /* DEBUG */
return(-1);
}
@@ -442,7 +455,7 @@ hs_parse(char *msg, char *eom)
key_cpy = strdup(key);
#ifdef DEBUG
dlog("hs_parse: Parsed key: %s, value: %s", key,
- value);
+ value);
#endif
mapc_add_kv(hs_map, key_cpy, value);
}
@@ -454,6 +467,7 @@ hs_parse(char *msg, char *eom)
/* Check to see if the domain name in the supplied argument matches
hs_domain. Strip hs_domain from supplied argument if so. */
+int
hs_strip_our_domain(char *name)
{
char *end_pos;
@@ -474,7 +488,8 @@ hs_strip_our_domain(char *name)
#define MAXDATA 8*1024
-char *hs_make_value(chr *cp, int len)
+char *
+hs_make_value(chr *cp, int len)
{
char *value, *cpcpy, *valuep;
int cnt, nextcnt, totalcnt, lencpy;
@@ -500,7 +515,7 @@ char *hs_make_value(chr *cp, int len)
if (totalcnt < 1 || totalcnt > MAXDATA || totalcnt > len) {
#ifdef DEBUG
dlog("TXT RR not of expected length (%d %d): %s", totalcnt,
- len, dbgname);
+ len, dbgname);
#endif /* DEBUG */
return(NULL);
}
@@ -522,13 +537,14 @@ char *hs_make_value(chr *cp, int len)
return(value);
}
+int
hs_make_ns_query(char *domain, char *ansbuf)
{
int status, len;
char buf[PACKETSZ];
if ((len = res_mkquery(QUERY, domain, C_HS, T_NS,
- (char *)NULL, 0, NULL, buf, PACKETSZ)) == -1) {
+ (char *)NULL, 0, NULL, buf, PACKETSZ)) == -1) {
#ifdef DEBUG
dlog("hs_get_ns_list: res_mkquery failed");
#endif
@@ -537,8 +553,8 @@ hs_make_ns_query(char *domain, char *ansbuf)
}
if ((status = res_send(buf, len, (char *)ansbuf, PACKETSZ)) == -1) {
#ifdef DEBUG
- dlog("hs_get_ns_list: res_send failed. status %d errno %d",
- status, errno);
+ dlog("hs_get_ns_list: res_send failed. status %d errno %d",
+ status, errno);
#endif
errno = 0;
return(-1);
@@ -546,15 +562,18 @@ hs_make_ns_query(char *domain, char *ansbuf)
return(0);
}
-static void add_address(struct in_addr *addr)
+static void
+add_address(struct in_addr *addr)
{
char dq[20];
+
bcopy((char *)addr, nsaddr_list[hs_nscount++], sizeof(struct in_addr));
#ifdef DEBUG
dlog("Adding NS address %s", inet_dquad(dq, sizeof(dq), addr->s_addr));
#endif /* DEBUG */
}
+int
hs_get_ns_list(char *domain)
{
register HEADER *hp;
@@ -578,7 +597,7 @@ hs_get_ns_list(char *domain)
if (hp->rcode != NOERROR || hp->opcode != QUERY) {
#ifdef DEBUG
dlog("Bad response (%d) from nameserver %#x", hp->rcode,
- hs_server_addr(servernum)->s_addr);
+ hs_server_addr(servernum)->s_addr);
#endif /* DEBUG */
return(-1);
}
@@ -651,7 +670,7 @@ hs_get_ns_list(char *domain)
if ((ghp = gethostbyname(nsname[i])) == 0)
continue;
for (hptr = (in_addr_t **)ghp->h_addr_list;
- *hptr && hs_nscount < MAX_NSADDR; hptr++) {
+ *hptr && hs_nscount < MAX_NSADDR; hptr++) {
add_address((struct in_addr *) *hptr);
}
}
diff --git a/usr.sbin/amd/amd/info_ndbm.c b/usr.sbin/amd/amd/info_ndbm.c
index ca5a6afb4f7..d13ea0a6d80 100644
--- a/usr.sbin/amd/amd/info_ndbm.c
+++ b/usr.sbin/amd/amd/info_ndbm.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_ndbm.c 8.1 (Berkeley) 6/6/93
- * $Id: info_ndbm.c,v 1.2 2002/07/18 00:50:23 pvalchev Exp $
+ * $Id: info_ndbm.c,v 1.3 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -51,9 +51,11 @@
#include <fcntl.h>
#include <sys/stat.h>
-static int search_ndbm(DBM *db, char *key, char **val)
+static int
+search_ndbm(DBM *db, char *key, char **val)
{
datum k, v;
+
k.dptr = key;
k.dsize = strlen(key) + 1;
v = dbm_fetch(db, k);
@@ -64,7 +66,8 @@ static int search_ndbm(DBM *db, char *key, char **val)
return ENOENT;
}
-int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
+int
+ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
{
DBM *db;
@@ -72,6 +75,7 @@ int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
if (db) {
struct stat stb;
int error;
+
error = fstat(dbm_pagfno(db), &stb);
if (!error && *tp < stb.st_mtime) {
*tp = stb.st_mtime;
@@ -86,7 +90,8 @@ int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
return errno;
}
-int ndbm_init(char *map, time_t *tp)
+int
+ndbm_init(char *map, time_t *tp)
{
DBM *db;
diff --git a/usr.sbin/amd/amd/info_nis.c b/usr.sbin/amd/amd/info_nis.c
index 7f6d4461e2c..e058302a1cb 100644
--- a/usr.sbin/amd/amd/info_nis.c
+++ b/usr.sbin/amd/amd/info_nis.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_nis.c 8.1 (Berkeley) 6/6/93
- * $Id: info_nis.c,v 1.6 2002/07/18 02:03:00 deraadt Exp $
+ * $Id: info_nis.c,v 1.7 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -60,9 +60,10 @@ static int has_yp_order = FALSE;
/*
* Figure out the nis domain name
*/
-static int determine_nis_domain(P_void)
+static int
+determine_nis_domain(P_void)
{
-static int nis_not_running = 0;
+ static int nis_not_running = 0;
char default_domain[YPMAXDOMAIN];
@@ -97,8 +98,9 @@ struct nis_callback_data {
/*
* Callback from yp_all
*/
-static int callback(int status, char *key, int kl, char *val,
- int vl, struct nis_callback_data *data)
+static int
+callback(int status, char *key, int kl, char *val,
+ int vl, struct nis_callback_data *data)
{
if (status == YP_TRUE) {
/*
@@ -106,6 +108,7 @@ static int callback(int status, char *key, int kl, char *val,
*/
char *kp = strnsave(key, kl);
char *vp = strnsave(val, vl);
+
(*data->ncd_fn)(data->ncd_m, kp, vp);
/*
@@ -124,17 +127,18 @@ static int callback(int status, char *key, int kl, char *val,
#ifdef DEBUG
plog(XLOG_ERROR, "yp enumeration of %s: %s, status=%d, e=%d",
- data->ncd_map, yperr_string(e), status, e);
+ data->ncd_map, yperr_string(e), status, e);
#else
- plog(XLOG_ERROR, "yp enumeration of %s: %s", data->ncd_map, yperr_string(e));
+ plog(XLOG_ERROR, "yp enumeration of %s: %s",
+ data->ncd_map, yperr_string(e));
#endif
}
-
return TRUE;
}
}
-int nis_reload(mnt_map *m, char *map, void (*fn)())
+int
+nis_reload(mnt_map *m, char *map, void (*fn)())
{
struct ypall_callback cbinfo;
int error;
@@ -155,7 +159,8 @@ int nis_reload(mnt_map *m, char *map, void (*fn)())
error = yp_all(domain, map, &cbinfo);
if (error)
- plog(XLOG_ERROR, "error grabbing nis map of %s: %s", map, yperr_string(ypprot_err(error)));
+ plog(XLOG_ERROR, "error grabbing nis map of %s: %s",
+ map, yperr_string(ypprot_err(error)));
return error;
}
@@ -164,11 +169,12 @@ int nis_reload(mnt_map *m, char *map, void (*fn)())
/*
* Try to locate a key using NIS.
*/
-int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp)
+int
+nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp)
{
int outlen;
- int res;
int order;
+ int res;
/*
* Make sure domain initialised
@@ -237,7 +243,8 @@ int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp)
}
}
-int nis_init(char *map, time_t *tp)
+int
+nis_init(char *map, time_t *tp)
{
int order;
int yp_order_result;
@@ -245,6 +252,7 @@ int nis_init(char *map, time_t *tp)
if (!domain) {
int error = determine_nis_domain();
+
if (error)
return error;
}
diff --git a/usr.sbin/amd/amd/info_passwd.c b/usr.sbin/amd/amd/info_passwd.c
index 035c75ee4d9..8d8cf70a119 100644
--- a/usr.sbin/amd/amd/info_passwd.c
+++ b/usr.sbin/amd/amd/info_passwd.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_passwd.c 8.1 (Berkeley) 6/6/93
- * $Id: info_passwd.c,v 1.5 2002/07/18 02:03:00 deraadt Exp $
+ * $Id: info_passwd.c,v 1.6 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -56,7 +56,8 @@
/*
* Nothing to probe - check the map name is PASSWD_MAP.
*/
-int passwd_init(char *map, time_t *tp)
+int
+passwd_init(char *map, time_t *tp)
{
*tp = 0;
return strcmp(map, PASSWD_MAP) == 0 ? 0 : ENOENT;
@@ -67,10 +68,12 @@ int passwd_init(char *map, time_t *tp)
* Grab the entry via the getpwname routine
* Modify time is ignored by passwd - XXX
*/
-int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
+int
+passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
{
- char *dir = 0;
struct passwd *pw;
+ char *dir = 0;
+
if (strcmp(key, "/defaults") == 0) {
*pval = strdup("type:=nfs");
return 0;
@@ -88,10 +91,9 @@ int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
* This allows cross-domain entries in your passwd file.
* ... but forget about security!
*/
- char *user;
- char *p, *q;
- char val[MAXPATHLEN];
- char rhost[MAXHOSTNAMELEN];
+ char val[MAXPATHLEN], rhost[MAXHOSTNAMELEN];
+ char *user, *p, *q;
+
dir = strdup(pw->pw_dir);
/*
* Find user name. If no / then Invalid...
@@ -123,6 +125,7 @@ int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
strlcat(rhost, p, sizeof(rhost));
}
} while (q);
+
/*
* Sanity check
*/
@@ -134,8 +137,9 @@ int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
q = strchr(rhost, '.');
if (q)
*q = '\0';
- snprintf(val, sizeof(val), "rfs:=%s/%s;rhost:=%s;sublink:=%s;fs:=${autodir}%s",
- dir, rhost, rhost, user, pw->pw_dir);
+ snprintf(val, sizeof(val),
+ "rfs:=%s/%s;rhost:=%s;sublink:=%s;fs:=${autodir}%s",
+ dir, rhost, rhost, user, pw->pw_dir);
if (q)
*q = '.';
*pval = strdup(val);
diff --git a/usr.sbin/amd/amd/info_union.c b/usr.sbin/amd/amd/info_union.c
index 9a866ef50da..2c7dba2113b 100644
--- a/usr.sbin/amd/amd/info_union.c
+++ b/usr.sbin/amd/amd/info_union.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_union.c 8.1 (Berkeley) 6/6/93
- * $Id: info_union.c,v 1.4 2002/07/18 00:50:23 pvalchev Exp $
+ * $Id: info_union.c,v 1.5 2002/07/18 02:14:45 deraadt Exp $
*/
/*
@@ -64,17 +64,20 @@
/*
* No way to probe - check the map name begins with "union:"
*/
-int union_init(char *map, time_t *tp)
+int
+union_init(char *map, time_t *tp)
{
*tp = 0;
return strncmp(map, UNION_PREFIX, UNION_PREFLEN) == 0 ? 0 : ENOENT;
}
-int union_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
+int
+union_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
{
char *mapd = strdup(map + UNION_PREFLEN);
char **v = strsplit(mapd, ':', '\"');
char **p;
+
for (p = v; p[1]; p++)
;
*pval = xmalloc(strlen(*p) + 5);
@@ -84,7 +87,8 @@ int union_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
return 0;
}
-int union_reload(mnt_map *m, char *map, void (*fn)())
+int
+union_reload(mnt_map *m, char *map, void (*fn)())
{
char *mapd = strdup(map + UNION_PREFLEN);
char **v = strsplit(mapd, ':', '\"');
@@ -93,12 +97,14 @@ int union_reload(mnt_map *m, char *map, void (*fn)())
/*
* Add fake /defaults entry
*/
- (*fn)(m, strdup("/defaults"), strdup("type:=link;opts:=nounmount;sublink:=${key}"));
+ (*fn)(m, strdup("/defaults"),
+ strdup("type:=link;opts:=nounmount;sublink:=${key}"));
for (dir = v; *dir; dir++) {
- int dlen;
- DIRENT *dp;
DIR *dirp = opendir(*dir);
+ DIRENT *dp;
+ int dlen;
+
if (!dirp) {
plog(XLOG_USER, "Cannot read directory %s: %m", *dir);
continue;
@@ -109,9 +115,10 @@ int union_reload(mnt_map *m, char *map, void (*fn)())
#endif
while ((dp = readdir(dirp))) {
char *val;
+
if (dp->d_name[0] == '.' &&
- (dp->d_name[1] == '\0' ||
- (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
+ (dp->d_name[1] == '\0' ||
+ (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
continue;
#ifdef DEBUG
@@ -123,12 +130,15 @@ int union_reload(mnt_map *m, char *map, void (*fn)())
}
closedir(dirp);
}
+
/*
* Add wildcard entry
*/
- { char *val = xmalloc(strlen(dir[-1]) + 5);
- snprintf(val, strlen(dir[-1]) + 5, "fs:=%s", dir[-1]);
- (*fn)(m, strdup("*"), val);
+ {
+ char *val = xmalloc(strlen(dir[-1]) + 5);
+
+ snprintf(val, strlen(dir[-1]) + 5, "fs:=%s", dir[-1]);
+ (*fn)(m, strdup("*"), val);
}
free(mapd);
free(v);