diff -urN autofs-0.3.14/.version autofs-0.3.15-pre1/.version --- autofs-0.3.14/.version Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/.version Tue Sep 30 16:48:00 1997 @@ -1 +1 @@ -0.3.14 +0.3.15 diff -urN autofs-0.3.14/Makefile autofs-0.3.15-pre1/Makefile --- autofs-0.3.14/Makefile Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/Makefile Tue Sep 30 16:48:00 1997 @@ -27,6 +27,8 @@ mrproper distclean: clean find . -noleaf \( -name '*~' -o -name '#*' -o -name '*.orig' -o -name '*.rej' -o -name '*.old' \) -print0 | xargs -0 rm -f +TODAY := $(shell date +'%Y%m%d') + backup: mrproper cd .. ; tar cf - autofs | gzip -9 > autofs-bu-$(TODAY).tar.gz diff -urN autofs-0.3.14/NEWS autofs-0.3.15-pre1/NEWS --- autofs-0.3.14/NEWS Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/NEWS Tue Sep 30 16:48:00 1997 @@ -1,3 +1,9 @@ +Since autofs-0.3.14: +-------------------- +* "const-ipated" the source at all module interface points, to keep me + from doing stupid things like calling strtok() on a string constant. +* Minor fix to the autofs(5) man page. + Since autofs-0.3.13: -------------------- * Simplified the signalling/forking structure. diff -urN autofs-0.3.14/daemon/automount.c autofs-0.3.15-pre1/daemon/automount.c --- autofs-0.3.14/daemon/automount.c Sat Sep 20 18:38:49 1997 +++ autofs-0.3.15-pre1/daemon/automount.c Tue Sep 30 16:47:59 1997 @@ -538,7 +538,8 @@ int main(int argc, char *argv[]) { - char *path, *map, *mapfmt, **mapargv; + char *path, *map, *mapfmt; + const char **mapargv; struct sigaction sa; int mapargc, opt; static const struct option long_options[] = { @@ -595,7 +596,7 @@ path = argv[0]; map = argv[1]; - mapargv = &argv[2]; + mapargv = (const char **) &argv[2]; mapargc = argc-2; syslog(LOG_INFO, "starting automounter version %s, path = %s, " diff -urN autofs-0.3.14/daemon/module.c autofs-0.3.15-pre1/daemon/module.c --- autofs-0.3.14/daemon/module.c Sat Sep 20 18:38:49 1997 +++ autofs-0.3.15-pre1/daemon/module.c Tue Sep 30 16:47:59 1997 @@ -11,8 +11,9 @@ #include #include "automount.h" -struct lookup_mod *open_lookup(char *name, char *err_prefix, - char *mapfmt, int argc, char **argv) +struct lookup_mod *open_lookup(const char *name, const char *err_prefix, + const char *mapfmt, + int argc, const char * const *argv) { struct lookup_mod *mod; char *fnbuf; @@ -76,8 +77,8 @@ return rv; } -struct parse_mod *open_parse(char *name, char *err_prefix, - int argc, char **argv) +struct parse_mod *open_parse(const char *name, const char *err_prefix, + int argc, const char * const *argv) { struct parse_mod *mod; char *fnbuf; @@ -141,7 +142,7 @@ return rv; } -struct mount_mod *open_mount(char *name, char *err_prefix) +struct mount_mod *open_mount(const char *name, const char *err_prefix) { struct mount_mod *mod; char *fnbuf; diff -urN autofs-0.3.14/daemon/mount.c autofs-0.3.15-pre1/daemon/mount.c --- autofs-0.3.14/daemon/mount.c Sat Sep 20 18:38:49 1997 +++ autofs-0.3.15-pre1/daemon/mount.c Tue Sep 30 16:47:59 1997 @@ -26,11 +26,12 @@ static char *not_generic[] = { "nfs", "smbfs", "ncpfs", "userfs", "autofs", NULL }; -int do_mount(char *root, char *name, int name_len, char *what, char *fstype, - char *options) +int do_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, const char *options) { struct mount_mod *mod; - char **ngp, *modstr; + const char *modstr; + char **ngp; int rv; mod = open_mount(modstr = fstype, NULL); diff -urN autofs-0.3.14/daemon/spawn.c autofs-0.3.15-pre1/daemon/spawn.c --- autofs-0.3.14/daemon/spawn.c Sat Sep 20 18:38:49 1997 +++ autofs-0.3.15-pre1/daemon/spawn.c Tue Sep 30 16:47:59 1997 @@ -47,7 +47,7 @@ #define ERRBUFSIZ 2047 /* Max length of error string excl \0 */ -int spawnv(int logpri, char *prog, char **argv) { +int spawnv(int logpri, const char *prog, const char * const *argv) { pid_t f; int status, pipefd[2]; char errbuf[ERRBUFSIZ+1], *p, *sp; @@ -70,7 +70,7 @@ dup2(pipefd[1], STDOUT_FILENO); dup2(pipefd[1], STDERR_FILENO); close(pipefd[1]); - execv(prog, argv); + execv(prog, (char * const *)argv); _exit(255); /* execv() failed */ } else { /* Careful here -- if we enable SIGCHLD yet we may not receive the @@ -133,7 +133,7 @@ } } -int spawnl(int logpri, char *prog, ...) +int spawnl(int logpri, const char *prog, ...) { va_list arg; int argc; @@ -151,6 +151,6 @@ while ((*p++ = va_arg(arg,char *))); va_end(arg); - return spawnv(logpri, prog, argv); + return spawnv(logpri, prog, (const char **)argv); } diff -urN autofs-0.3.14/include/automount.h autofs-0.3.15-pre1/include/automount.h --- autofs-0.3.14/include/automount.h Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/include/automount.h Tue Sep 30 16:48:00 1997 @@ -26,10 +26,11 @@ /* Standard function used by daemon or modules */ -int spawnl(int, char *, ...); -int spawnv(int, char *, char **); +int spawnl(int logpri, const char *prog, ...); +int spawnv(int logpri, const char *prog, const char * const *argv); void reset_signals(void); -int do_mount(char *, char *, int, char *, char *, char *); +int do_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, const char *options); /* Prototype for module functions */ @@ -38,12 +39,13 @@ #define AUTOFS_LOOKUP_VERSION 4 #ifdef MODULE_LOOKUP -int lookup_init(char *, int, char **, void **); -int lookup_mount(char *, char *, int, void *); +int lookup_init(const char *mapfmt, int argc, const char * const *argv, + void **context); +int lookup_mount(const char *, const char *, int, void *); int lookup_done(void *); #endif -typedef (*lookup_init_t)(char *, int, char **, void **); -typedef (*lookup_mount_t)(char *, char *, int, void *); +typedef (*lookup_init_t)(const char *, int, const char * const *, void **); +typedef (*lookup_mount_t)(const char *, const char *, int, void *); typedef (*lookup_done_t)(void *); struct lookup_mod { lookup_init_t lookup_init; @@ -52,7 +54,9 @@ void *dlhandle; void *context; }; -struct lookup_mod *open_lookup(char *, char *, char *, int, char **); +struct lookup_mod *open_lookup(const char *name, const char *err_prefix, + const char *mapfmt, + int argc, const char * const *argv); int close_lookup(struct lookup_mod *); /* parse module */ @@ -60,12 +64,13 @@ #define AUTOFS_PARSE_VERSION 3 #ifdef MODULE_PARSE -int parse_init(int, char **, void **); -int parse_mount(char *, char *, int, char *, void *); +int parse_init(int argc, const char * const *argv, void **context); +int parse_mount(const char *root, const char *name, + int name_len, const char *mapent, void *context); int parse_done(void *); #endif -typedef (*parse_init_t)(int, char **, void **); -typedef (*parse_mount_t)(char *, char *, int, char *, void *); +typedef (*parse_init_t)(int, const char * const *,void **); +typedef (*parse_mount_t)(const char *,const char *,int, const char *,void *); typedef (*parse_done_t)(void *); struct parse_mod { parse_init_t parse_init; @@ -74,7 +79,8 @@ void *dlhandle; void *context; }; -struct parse_mod *open_parse(char *, char *, int, char **); +struct parse_mod *open_parse(const char *name, const char *err_prefix, + int argc, const char * const *argv); int close_parse(struct parse_mod *); /* mount module */ @@ -82,12 +88,14 @@ #define AUTOFS_MOUNT_VERSION 4 #ifdef MODULE_MOUNT -int mount_init(void **); -int mount_mount(char *, char *, int, char *, char *, char *, void *); -int mount_done(void *); +int mount_init(void **context); +int mount_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, const char *options, + void *context); +int mount_done(void *context); #endif typedef (*mount_init_t)(void **); -typedef (*mount_mount_t)(char *, char *, int, char *, char *, char *, void *); +typedef (*mount_mount_t)(const char *, const char *, int, const char *, const char *, const char *, void *); typedef (*mount_done_t)(void *); struct mount_mod { mount_init_t mount_init; @@ -96,9 +104,8 @@ void *dlhandle; void *context; }; -struct mount_mod *open_mount(char *, char *); +struct mount_mod *open_mount(const char *name, const char *err_prefix); int close_mount(struct mount_mod *); #endif /* AUTOMOUNT_H */ - diff -urN autofs-0.3.14/man/autofs.5 autofs-0.3.15-pre1/man/autofs.5 --- autofs-0.3.14/man/autofs.5 Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/man/autofs.5 Tue Sep 30 16:47:59 1997 @@ -1,5 +1,5 @@ .\" t -.TH AUTOFS 5 "9 Sep 1997" +.TH AUTOFS 5 "29 Sep 1997" .SH NAME autofs \- Format of the automounter maps .SH "DESCRIPTION" @@ -42,10 +42,11 @@ The location specifies from where the file system is to be mounted. In the most cases this will be an NFS volume and the usual notation .I host:pathname -is used to indicate the remote filesystem and path to be mounted. If a local -device needs to be specified as the location then a : needs to be prefixed -to the device name (e.g. :/dev/sda1) in order to let the automounter know -that no hostname will be following. +is used to indicate the remote filesystem and path to be mounted. If +the filesystem to be mounted begins with a / (such as local +.I /dev +entries or smbfs shares) a : needs to be prefixed (e.g. +.IR :/dev/sda1 ). .SH EXAMPLE .sp .RS +.2i @@ -53,6 +54,7 @@ .nf kernel -ro,soft,intr ftp.kernel.org:/pub/linux boot -fstype=ext2 :/dev/hda1 +windoze -fstype=smbfs ://windoze/c removable -fstype=ext2 :/dev/hdd cd -fstype=iso9660,ro :/dev/hdc floppy -fstype=auto :/dev/fd0 @@ -62,7 +64,9 @@ In the first line we have a NFS remote mount of the kernel directory on .IR ftp.kernel.org . This is mounted read-only. The second line mounts an ext2 volume on a -local ide drive. The rest should be fairly self explanatory. +local ide drive. The third makes a share exported from a Windows +machine available for automounting. The rest should be fairly +self-explanatory. .SH FEATURES .SS Map Key Substitution An & character in the diff -urN autofs-0.3.14/modules/lookup_file.c autofs-0.3.15-pre1/modules/lookup_file.c --- autofs-0.3.14/modules/lookup_file.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/lookup_file.c Tue Sep 30 16:47:59 1997 @@ -24,13 +24,14 @@ #define MAPENT_MAX_LEN 4095 struct lookup_context { - char *mapname; + const char *mapname; struct parse_mod *parse; }; int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */ -int lookup_init(char *mapfmt, int argc, char **argv, void **context) +int lookup_init(const char *mapfmt, int argc, const char * const *argv, + void **context) { struct lookup_context *ctxt; @@ -61,11 +62,13 @@ return !(ctxt->parse = open_parse(mapfmt,MODPREFIX,argc-1,argv+1)); } -int lookup_mount(char *root, char *name, int name_len, void *context) +int lookup_mount(const char *root, const char *name, int name_len, + void *context) { struct lookup_context *ctxt = (struct lookup_context *) context; int ch, nch; - char mapent[MAPENT_MAX_LEN+1], *p, *nptr; + char mapent[MAPENT_MAX_LEN+1], *p; + const char *nptr; int mapent_len; FILE *f; enum { @@ -88,7 +91,7 @@ gotten = got_nothing; /* Shut up gcc */ - p = nptr = NULL; + nptr = p = NULL; mapent_len = 0; getting = got_nothing; escape = esc_none; diff -urN autofs-0.3.14/modules/lookup_program.c autofs-0.3.15-pre1/modules/lookup_program.c --- autofs-0.3.14/modules/lookup_program.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/lookup_program.c Tue Sep 30 16:47:59 1997 @@ -28,13 +28,14 @@ #define MAPENT_MAX_LEN 4095 struct lookup_context { - char *mapname; + const char *mapname; struct parse_mod *parse; }; int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */ -int lookup_init(char *mapfmt, int argc, char **argv, void **context) +int lookup_init(const char *mapfmt, int argc, const char * const *argv, + void **context) { struct lookup_context *ctxt; @@ -65,7 +66,8 @@ return !(ctxt->parse = open_parse(mapfmt,MODPREFIX,argc-1,argv+1)); } -int lookup_mount(char *root, char *name, int name_len, void *context) +int lookup_mount(const char *root, const char *name, int name_len, + void *context) { struct lookup_context *ctxt = (struct lookup_context *) context; char mapent[MAPENT_MAX_LEN+1], *mapp; diff -urN autofs-0.3.14/modules/lookup_yp.c autofs-0.3.15-pre1/modules/lookup_yp.c --- autofs-0.3.14/modules/lookup_yp.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/lookup_yp.c Tue Sep 30 16:47:59 1997 @@ -25,14 +25,15 @@ #define MODPREFIX "lookup(yp): " struct lookup_context { - char *domainname; - char *mapname; + const char *domainname; + const char *mapname; struct parse_mod *parse; }; int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */ -int lookup_init(char *mapfmt, int argc, char **argv, void **context) +int lookup_init(const char *mapfmt, int argc, const char * const *argv, + void **context) { struct lookup_context *ctxt; int err; @@ -48,7 +49,8 @@ } ctxt->mapname = argv[0]; - err = yp_get_default_domain(&ctxt->domainname); + /* This should, but doesn't, take a const char ** */ + err = yp_get_default_domain((char **) &ctxt->domainname); if ( err ) { syslog(LOG_CRIT, MODPREFIX "map %s: %s\n", ctxt->mapname, yperr_string(err)); return 1; @@ -60,7 +62,8 @@ return !(ctxt->parse = open_parse(mapfmt,MODPREFIX,argc-1,argv+1)); } -int lookup_mount(char *root, char *name, int name_len, void *context) +int lookup_mount(const char *root, const char *name, + int name_len, void *context) { struct lookup_context *ctxt = (struct lookup_context *) context; char *mapent; @@ -69,11 +72,16 @@ syslog(LOG_DEBUG, MODPREFIX "looking up %s", name); - err = yp_match(ctxt->domainname,ctxt->mapname,name,name_len,&mapent,&mapent_len); + /* For reasons unknown, the standard YP definitions doesn't define input + strings as const char *. However, my understanding is that they will + not be modified by the library. */ + err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname, + (char *) name, name_len, &mapent, &mapent_len); if ( err == YPERR_KEY ) { /* Try to get the "*" entry if there is one - note that we *don't* modify "name" so & -> the name we used, not "*" */ - err = yp_match(ctxt->domainname,ctxt->mapname,"*",1,&mapent,&mapent_len); + err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname, + "*", 1, &mapent, &mapent_len); } if ( err ) { syslog(LOG_NOTICE, MODPREFIX "lookup for %s failed: %s", name, yperr_string(err)); diff -urN autofs-0.3.14/modules/mount_generic.c autofs-0.3.15-pre1/modules/mount_generic.c --- autofs-0.3.14/modules/mount_generic.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/mount_generic.c Tue Sep 30 16:47:59 1997 @@ -29,8 +29,9 @@ return 0; } -int mount_mount(char *root, char *name, int name_len, char *what, - char *fstype, char *options, void *context) +int mount_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, const char *options, + void *context) { char *fullpath; int err; diff -urN autofs-0.3.14/modules/mount_nfs.c autofs-0.3.15-pre1/modules/mount_nfs.c --- autofs-0.3.14/modules/mount_nfs.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/mount_nfs.c Tue Sep 30 16:47:59 1997 @@ -46,8 +46,9 @@ return 0; } -int mount_mount(char *root, char *name, int name_len, char *what, - char *fstype, char *options, void *context) +int mount_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, + const char *options, void *context) { char *colon, **haddr, *fullpath; struct hostent *he; diff -urN autofs-0.3.14/modules/mount_smbfs.c autofs-0.3.15-pre1/modules/mount_smbfs.c --- autofs-0.3.14/modules/mount_smbfs.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/mount_smbfs.c Tue Sep 30 16:47:59 1997 @@ -62,7 +62,8 @@ return 0; } -static int smb_parse_options(char *optstr,char **argv,char *qbuf,int *qbuflen) +static int smb_parse_options(char *optstr, const char **argv, + char *qbuf, int *qbuflen) { char *opt; int ln; @@ -123,14 +124,15 @@ return argc; } -int mount_mount(char *root, char *name, int name_len, char *what, - char *fstype, char *options, void *context) +int mount_mount(const char *root, const char *name, int name_len, + const char *what, const char *fstype, const char *options, + void *context) { char *fullpath, *optcopy; int err; char *qbuf; int argc, optsize, qbuflen; - char **argv; + const char **argv; fullpath = alloca(strlen(root)+name_len+2); optcopy = alloca(optsize = strlen(options)+1); diff -urN autofs-0.3.14/modules/parse_sun.c autofs-0.3.15-pre1/modules/parse_sun.c --- autofs-0.3.14/modules/parse_sun.c Sat Sep 20 18:38:50 1997 +++ autofs-0.3.15-pre1/modules/parse_sun.c Tue Sep 30 16:47:59 1997 @@ -80,7 +80,8 @@ } /* Find the $-variable matching a certain string fragment */ -static struct substvar *findvar(struct substvar *sv, char *str, int len) +static const struct substvar *findvar(const struct substvar *sv, + const char *str, int len) { while ( sv ) { if ( !strncmp(str,sv->def,len) && sv->def[len] == '\0' ) @@ -92,12 +93,13 @@ /* $- and &-expand a Sun-style map entry and return the length of the entry. If "dst" is NULL, just count the length. */ -static int expandsunent(char *src, char *dst, char *key, struct substvar *svc, - int slashify_colons) +static int expandsunent(const char *src, char *dst, const char *key, + const struct substvar *svc, int slashify_colons) { - struct substvar *sv; + const struct substvar *sv; int len, l, seen_colons; - char *p, ch; + const char *p; + char ch; len = 0; seen_colons = 0; @@ -224,7 +226,7 @@ /* Compare str with pat. Return 0 if compare equal or str is an abbreviation of pat of no less than mchr characters. */ -int strmcmp(char *str, char *pat, int mchr) +int strmcmp(const char *str, const char *pat, int mchr) { int nchr = 0; @@ -239,11 +241,12 @@ return *pat - *str; } -int parse_init(int argc, char **argv, void **context) +int parse_init(int argc, const char * const *argv, void **context) { struct parse_context *ctxt; struct substvar *sv; char *noptstr; + const char *xopt; int optlen, len; int i, bval; @@ -307,16 +310,15 @@ case '-': if ( !strncmp(argv[i]+2, "no-", 3) ) { - noptstr = argv[i]+5; + xopt = argv[i]+5; bval = 0; } else { - noptstr = argv[i]+2; + xopt = argv[i]+2; bval = 1; } - if ( strmcmp(noptstr, "slashify-colons", 1) ) { + if ( strmcmp(xopt, "slashify-colons", 1) ) ctxt->slashify_colons = bval; - } else syslog(LOG_ERR, MODPREFIX "unknown option: %s", argv[i]); @@ -366,7 +368,8 @@ } } -int parse_mount(char *root, char *name, int name_len, char *mapent, void *context) +int parse_mount(const char *root, const char *name, + int name_len, const char *mapent, void *context) { struct parse_context *ctxt = (struct parse_context *) context; char *pmapent, *options, *noptions, *ent, *p, *q, *fstype;