05f79e89d4a8ae529424ec1cce8d4fdff793f140
* Copyright (c) 1989 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Herb Hasler and Rick Macklem at The University of Guelph.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1989 Regents of the University of California.\n\
static char sccsid
[] = "@(#)mountd.c 5.18 (Berkeley) %G%";
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
char name
[RPCMNT_NAMELEN
+1];
char gname
[RPCMNT_NAMELEN
+1];
* Structures for keeping the mount list and export list
struct mountlist
*ml_next
;
char ml_host
[RPCMNT_NAMELEN
+1];
char ml_dirp
[RPCMNT_PATHLEN
+1];
struct exportlist
*ex_next
;
struct exportlist
*ex_prev
;
struct grouplist
*ex_groups
;
char ex_dirp
[RPCMNT_PATHLEN
+1];
struct hostent
*gt_hostent
;
struct groupnames
*gt_grpname
;
struct sockaddr_iso
*gt_isoaddr
;
struct grouplist
*gr_next
;
char gn_name
[RPCMNT_NAMELEN
+1];
struct grouplist
*gn_glist
;
struct groupnames
*gn_next
;
int mntsrv(), umntall_each(), xdr_fhs(), xdr_mlist(), xdr_dir(), xdr_explist();
void get_exportlist(), send_umntall(), nextfield(), do_opt();
void get_mountlist(), add_mlist(), del_mlist(), free_exp(), free_grp();
void get_group(), get_host(), do_group();
struct iso_addr
*iso_addr();
struct exportlist exphead
;
struct mountlist
*mlhead
;
struct groupnames
*grpnames
;
struct ucred def_anon
= {
struct al_mnt
*al_head
= (struct al_mnt
*)0;
void SYSLOG
__P((int, const char *, ...));
* Mountd server for NFS mount protocol as described in:
* NFS: Network File System Protocol Specification, RFC1094, Appendix A
* The optional arguments are the exports file name
* and "-n" to allow nonroot mount.
while ((c
= getopt(argc
, argv
, "n")) != EOF
)
fprintf(stderr
, "Usage: mountd [-n] [export_file]\n");
grpnames
= (struct groupnames
*)0;
exphead
.ex_next
= exphead
.ex_prev
= (struct exportlist
*)0;
mlhead
= (struct mountlist
*)0;
strncpy(exname
, *argv
, MAXPATHLEN
-1);
exname
[MAXPATHLEN
-1] = '\0';
strcpy(exname
, _PATH_EXPORTS
);
openlog("mountd:", LOG_PID
, LOG_DAEMON
);
fprintf(stderr
,"Getting export list.\n");
fprintf(stderr
,"Getting mount list.\n");
fprintf(stderr
,"Here we go.\n");
signal(SIGQUIT
, SIG_IGN
);
signal(SIGHUP
, get_exportlist
);
signal(SIGTERM
, send_umntall
);
{ FILE *pidfile
= fopen(_PATH_MOUNTDPID
, "w");
fprintf(pidfile
, "%d\n", getpid());
if ((transp
= svcudp_create(RPC_ANYSOCK
)) == NULL
) {
syslog(LOG_ERR
, "Can't create socket");
pmap_unset(RPCPROG_MNT
, RPCMNT_VER1
);
if (!svc_register(transp
, RPCPROG_MNT
, RPCMNT_VER1
, mntsrv
,
syslog(LOG_ERR
, "Can't register mount");
syslog(LOG_ERR
, "Mountd died");
register struct svc_req
*rqstp
;
register SVCXPRT
*transp
;
register struct grouplist
*grp
;
register struct exportlist
*ep
;
struct authunix_parms
*ucr
;
char rpcpath
[RPCMNT_PATHLEN
+1], dirpath
[MAXPATHLEN
];
switch (rqstp
->rq_cred
.oa_flavor
) {
ucr
= (struct authunix_parms
*)rqstp
->rq_clntcred
;
saddr
= transp
->xp_raddr
.sin_addr
.s_addr
;
hp
= (struct hostent
*)0;
switch (rqstp
->rq_proc
) {
if (!svc_sendreply(transp
, xdr_void
, (caddr_t
)0))
syslog(LOG_ERR
, "Can't send reply");
if ((uid
!= 0 && root_only
) || uid
== -2) {
if (!svc_getargs(transp
, xdr_dir
, rpcpath
)) {
* Get the real pathname and make sure it is a directory
if (realpath(rpcpath
, dirpath
) == 0 || stat(dirpath
, &stb
) < 0
|| (stb
.st_mode
&S_IFMT
) != S_IFDIR
) {
chdir("/"); /* Just in case realpath doesn't */
fprintf(stderr
,"stat failed on %s\n",dirpath
);
if (!svc_sendreply(transp
, xdr_long
, (caddr_t
)&bad
))
syslog(LOG_ERR
, "Can't send reply");
/* Check in the exports list */
omask
= sigblock(sigmask(SIGHUP
));
while (ep
!= NULL
&& !found
&& !matched
) {
fprintf(stderr
,"dirp=[%s]\n",ep
->ex_dirp
);
if (!strcmp(ep
->ex_dirp
, dirpath
)) {
grp
= (struct grouplist
*)0;
fprintf(stderr
,"grp is null\n");
fprintf(stderr
,"type = [%d]\n",grp
->type
);
if (grp
->type
== MNT_GROUP
) {
tgrp
= grp
->gr_ptr
.gt_grpname
->gn_glist
;
tgrp
->gr_ptr
.gt_hostent
->h_addr_list
;
fprintf(stderr
, "cmp [%d] [%d]\n",
hp
= tgrp
->gr_ptr
.gt_hostent
;
addrp
= (u_long
**)tgrp
->
gr_ptr
.gt_hostent
->h_addr_list
;
} else if (grp
->type
== MNT_HOST
) {
grp
->gr_ptr
.gt_hostent
->h_addr_list
;
fprintf(stderr
, "cmp [%d] [%d]\n",
hp
= grp
->gr_ptr
.gt_hostent
;
if (!svc_sendreply(transp
, xdr_long
, (caddr_t
)&bad
))
syslog(LOG_ERR
, "Can't send reply");
/* Get the file handle */
bzero((caddr_t
)&nfh
, sizeof(nfh
));
if (getfh(dirpath
, (fhandle_t
*)&nfh
) < 0) {
"Couldn't get file handle for %s.\n",
if (!svc_sendreply(transp
, xdr_long
,
syslog(LOG_ERR
, "Can't send reply");
if (!svc_sendreply(transp
, xdr_fhs
, (caddr_t
)&nfh
))
syslog(LOG_ERR
, "Can't send reply");
hp
= gethostbyaddr((caddr_t
)&saddr
,
add_mlist(hp
->h_name
, dirpath
);
add_mlist(inet_ntoa(transp
->xp_raddr
.sin_addr
),
fprintf(stderr
,"Mount successfull.\n");
if (!svc_sendreply(transp
, xdr_mlist
, (caddr_t
)0))
syslog(LOG_ERR
, "Can't send reply");
if ((uid
!= 0 && root_only
) || uid
== -2) {
if (!svc_getargs(transp
, xdr_dir
, dirpath
)) {
if (!svc_sendreply(transp
, xdr_void
, (caddr_t
)0))
syslog(LOG_ERR
, "Can't send reply");
hp
= gethostbyaddr((caddr_t
)&saddr
, sizeof(saddr
), AF_INET
);
del_mlist(hp
->h_name
, dirpath
);
del_mlist(inet_ntoa(transp
->xp_raddr
.sin_addr
), dirpath
);
if ((uid
!= 0 && root_only
) || uid
== -2) {
if (!svc_sendreply(transp
, xdr_void
, (caddr_t
)0))
syslog(LOG_ERR
, "Can't send reply");
hp
= gethostbyaddr((caddr_t
)&saddr
, sizeof(saddr
), AF_INET
);
del_mlist(hp
->h_name
, (char *)0);
del_mlist(inet_ntoa(transp
->xp_raddr
.sin_addr
), (char *)0);
if (!svc_sendreply(transp
, xdr_explist
, (caddr_t
)0))
syslog(LOG_ERR
, "Can't send reply");
* Xdr conversion for a dirpath string
return (xdr_string(xdrsp
, &dirp
, RPCMNT_PATHLEN
));
* Xdr routine to generate fhstatus
if (!xdr_long(xdrsp
, &ok
))
return (xdr_opaque(xdrsp
, (caddr_t
)nfh
, NFSX_FH
));
register struct mountlist
*mlp
;
if (!xdr_bool(xdrsp
, &true))
if (!xdr_string(xdrsp
, &strp
, RPCMNT_NAMELEN
))
if (!xdr_string(xdrsp
, &strp
, RPCMNT_PATHLEN
))
if (!xdr_bool(xdrsp
, &false))
* Xdr conversion for export list
register struct exportlist
*ep
;
register struct grouplist
*grp
, *tgrp
;
omask
= sigblock(sigmask(SIGHUP
));
if (!xdr_bool(xdrsp
, &true))
if (!xdr_string(xdrsp
, &strp
, RPCMNT_PATHLEN
))
if (grp
->type
== MNT_GROUP
) {
tgrp
= grp
->gr_ptr
.gt_grpname
->gn_glist
;
if (!xdr_bool(xdrsp
, &true))
strp
= tgrp
->gr_ptr
.gt_hostent
->h_name
;
if (!xdr_string(xdrsp
, &strp
,
} else if (grp
->type
== MNT_HOST
) {
if (!xdr_bool(xdrsp
, &true))
strp
= grp
->gr_ptr
.gt_hostent
->h_name
;
if (!xdr_string(xdrsp
, &strp
, RPCMNT_NAMELEN
))
if (!xdr_bool(xdrsp
, &false))
if (!xdr_bool(xdrsp
, &false))
struct grouplist
*grp
, *tgrp
;
struct al_mnt
*al_mp
, *t_almp
;
register struct exportlist
*ep
, *ep2
;
struct groupnames
*t_gn
, *t_gn2
;
int len
, dirplen
, def_set
;
* First, get rid of the old list
exphead
.ex_next
= exphead
.ex_prev
= (struct exportlist
*)0;
grpnames
= (struct groupnames
*)0;
al_head
= (struct al_mnt
*)0;
* Read in the exports file and build the list, calling
* mount() as we go along to push the export rules into the kernel.
if ((inf
= fopen(exname
, "r")) == NULL
) {
syslog(LOG_ERR
, "Can't open %s", exname
);
while (fgets(line
, LINESIZ
, inf
)) {
fprintf(stderr
,"Got line %s\n",line
);
/* create group listing of names */
* Create new exports list entry
if (len
<= RPCMNT_PATHLEN
&& len
> 0) {
* See if this directory is already in the list.
if (!strcmp(ep
->ex_dirp
, cp
))
if (ep
== (struct exportlist
*)0) {
ep
= (struct exportlist
*)malloc(sizeof(*ep
));
ep
->ex_next
= (struct exportlist
*)0;
ep
->ex_prev
= (struct exportlist
*)0;
ep
->ex_groups
= (struct grouplist
*)0;
bcopy(cp
, ep
->ex_dirp
, len
);
fprintf(stderr
, "Making new ep. [%s]\n",
syslog(LOG_ERR
, "Bad Exports File line: %s\n", line
);
if (len
> RPCMNT_NAMELEN
)
do_opt(cp
+ 1, ep
, &exflags
, &anoncr
);
fprintf(stderr
, "got r=%d, ex=%d\n",
do_group(cp
+ 1, endcp
, &grp
);
get_host(cp
, endcp
, ep
, &grp
);
grp
->gr_next
= ep
->ex_groups
;
if (ep
->ex_defset
== TRUE
)
syslog(LOG_ERR
, "Default specified again dir:%s\n",
fprintf(stderr
,"Adding a default entry\n");
/* add a default group and make the grp list NULL */
hpe
= (struct hostent
*)malloc(sizeof(struct hostent
));
syslog(LOG_ERR
,"No more memory: mountd Failed");
tgrp
= (struct grouplist
*)
malloc(sizeof(struct grouplist
));
syslog(LOG_ERR
,"No more memory: mountd Failed");
hpe
->h_addrtype
= AF_INET
;
hpe
->h_length
= sizeof (u_long
);
hpe
->h_addr_list
= (char **)0;
tgrp
->gr_ptr
.gt_hostent
= hpe
;
tgrp
->gr_next
= ep
->ex_groups
;
if (grp
->type
== MNT_GROUP
) {
tgrp
= grp
->gr_ptr
.gt_grpname
->gn_glist
;
if (do_mount(ep
, tgrp
, exflags
, &anoncr
,
if (do_mount(ep
, grp
, exflags
, &anoncr
, dirplen
)
if (ep
->ex_prev
== (struct exportlist
*)0) {
ep
->ex_next
= exphead
.ex_next
;
ep
->ex_next
->ex_prev
= ep
;
syslog(LOG_ERR
, "No more memory: mountd Failed");
do_mount(ep
, grp
, exflags
, anoncrp
, dirplen
)
struct ufs_args args
, targs
;
sin
.sin_family
= AF_INET
;
sin
.sin_len
= sizeof(sin
);
if (grp
->type
== MNT_HOST
)
addrp
= (u_long
**)grp
->gr_ptr
.gt_hostent
->h_addr_list
;
if (grp
->type
== MNT_HOST
) {
if (grp
->gr_ptr
.gt_hostent
->h_name
)
sin
.sin_addr
.s_addr
= **addrp
;
sin
.sin_addr
.s_addr
= INADDR_ANY
;
args
.saddr
= (struct sockaddr
*)&sin
;
} else if (grp
->type
== MNT_ISO
) {
args
.saddr
= (struct sockaddr
*)grp
->gr_ptr
.gt_isoaddr
;
args
.slen
= sizeof (struct sockaddr_iso
);
syslog(LOG_ERR
, "Bad grouptype");
if (statfs(ep
->ex_dirp
, &stfsbuf
) < 0) {
fprintf(stderr
,"statfs failed.\n");
syslog(LOG_ERR
, "Invalid path: %s", ep
->ex_dirp
);
for (al_mp
= al_head
; al_mp
&& !found
; al_mp
= al_mp
->al_next
)
if (al_mp
->al_mnted
.val
[0] == stfsbuf
.f_fsid
.val
[0] &&
al_mp
->al_mnted
.val
[1] == stfsbuf
.f_fsid
.val
[1])
/* first time for fs, so must send a MNT_DELEXPORT
* to clear the old export list held in the kernel
al_mp
= (struct al_mnt
*)malloc(sizeof (struct al_mnt
));
al_mp
->al_mnted
= stfsbuf
.f_fsid
;
al_mp
->al_next
= al_head
;
targs
.exflags
= MNT_DELEXPORT
;
while (mount(MOUNT_UFS
, ep
->ex_dirp
,
stfsbuf
.f_flags
| MNT_UPDATE
, &targs
) < 0) {
cp
= ep
->ex_dirp
+ dirplen
- 1;
/* back up over the last component */
while (*cp
== '/' && cp
> ep
->ex_dirp
)
while (*(cp
- 1) != '/' && cp
> ep
->ex_dirp
)
fprintf(stderr
,"mnt unsucc\n");
"Can't export %s", ep
->ex_dirp
);
while (mount(MOUNT_UFS
, ep
->ex_dirp
,
stfsbuf
.f_flags
| MNT_UPDATE
, &args
) < 0) {
"Can't change attributes for %s.\n",
cp
= ep
->ex_dirp
+ dirplen
- 1;
/* back up over the last component */
while (*cp
== '/' && cp
> ep
->ex_dirp
)
while (*(cp
- 1) != '/' && cp
> ep
->ex_dirp
)
fprintf(stderr
,"mnt unsucc\n");
syslog(LOG_ERR
, "Can't export %s", ep
->ex_dirp
);
* Parse out the next white space separated field
while (*p
== ' ' || *p
== '\t')
if (*p
== '\n' || *p
== '\0') {
while (*p
!= ' ' && *p
!= '\t' && *p
!= '\n' && *p
!= '\0')
* Parse the option string
do_opt(cpopt
, ep
, exflagsp
, cr
)
register char *cpoptarg
, *cpoptend
;
while (cpopt
&& *cpopt
) {
if (cpoptend
= index(cpopt
, ','))
if (cpoptarg
= index(cpopt
, '='))
if (!strcmp(cpopt
, "ro") || !strcmp(cpopt
, "o")) {
*exflagsp
|= MNT_EXRDONLY
;
} else if ((!strcmp(cpopt
, "root") || !strcmp(cpopt
, "r") ||
!(allflag
= strcmp(cpopt
, "all"))) && cpoptarg
) {
*exflagsp
|= MNT_EXPORTANON
;
} else if (!strcmp(cpopt
, "kerb") || !strcmp(cpopt
, "k")) {
syslog(LOG_ERR
, "opt %s ignored for %s", cpopt
,
* Parse a description of a credential.
register struct ucred
*cr
;
int ngroups
, groups
[NGROUPS
+ 1];
* Set up the unpriviledged user.
* Get the user's password table entry.
names
= strsep(&namelist
, " \t\n");
name
= strsep(&names
, ":");
if (isdigit(*name
) || *name
== '-')
pw
= getpwuid(atoi(name
));
* Credentials specified as those of a user.
syslog(LOG_ERR
, "Unknown user: %s\n", name
);
if (getgrouplist(pw
->pw_name
, pw
->pw_gid
, groups
, &ngroups
))
syslog(LOG_ERR
, "Too many groups\n");
* Convert from int's to gid_t's and compress out duplicate
cr
->cr_ngroups
= ngroups
- 1;
cr
->cr_groups
[0] = groups
[0];
for (cnt
= 2; cnt
< ngroups
; cnt
++)
cr
->cr_groups
[cnt
- 1] = groups
[cnt
];
* Explicit credential specified as a colon separated list:
else if (isdigit(*name
) || *name
== '-')
syslog(LOG_ERR
, "Unknown user: %s\n", name
);
while (names
!= NULL
&& *names
!= '\0' && cr
->cr_ngroups
< NGROUPS
) {
name
= strsep(&names
, ":");
if (isdigit(*name
) || *name
== '-') {
cr
->cr_groups
[cr
->cr_ngroups
++] = atoi(name
);
if ((gr
= getgrnam(name
)) == NULL
) {
syslog(LOG_ERR
, "Unknown group: %s\n", name
);
cr
->cr_groups
[cr
->cr_ngroups
++] = gr
->gr_gid
;
if (names
!= NULL
&& *names
!= '\0' && cr
->cr_ngroups
== NGROUPS
)
syslog(LOG_ERR
, "Too many groups\n");
#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50)
* Routines that maintain the remote mounttab
register struct mountlist
*mlp
, **mlpp
;
register char *eos
, *dirp
;
if ((mlfile
= fopen(_PATH_RMOUNTLIST
, "r")) == NULL
) {
syslog(LOG_ERR
, "Can't open %s", _PATH_RMOUNTLIST
);
while (fgets(str
, STRSIZ
, mlfile
) != NULL
) {
if ((dirp
= index(str
, '\t')) == NULL
&&
(dirp
= index(str
, ' ')) == NULL
)
mlp
= (struct mountlist
*)malloc(sizeof (*mlp
));
if (len
> RPCMNT_NAMELEN
)
bcopy(str
, mlp
->ml_host
, len
);
mlp
->ml_host
[len
] = '\0';
while (*dirp
== '\t' || *dirp
== ' ')
if ((eos
= index(dirp
, '\t')) == NULL
&&
(eos
= index(dirp
, ' ')) == NULL
&&
(eos
= index(dirp
, '\n')) == NULL
)
if (len
> RPCMNT_PATHLEN
)
bcopy(dirp
, mlp
->ml_dirp
, len
);
mlp
->ml_dirp
[len
] = '\0';
mlp
->ml_next
= (struct mountlist
*)0;
register char *hostp
, *dirp
;
register struct mountlist
*mlp
, **mlpp
;
if (!strcmp(mlp
->ml_host
, hostp
) &&
(!dirp
|| !strcmp(mlp
->ml_dirp
, dirp
))) {
*mlpp
= mlp
= mlp
->ml_next
;
if ((mlfile
= fopen(_PATH_RMOUNTLIST
, "w")) == NULL
) {
syslog(LOG_WARNING
,"Can't update %s", _PATH_RMOUNTLIST
);
fprintf(mlfile
, "%s %s\n", mlp
->ml_host
, mlp
->ml_dirp
);
register char *hostp
, *dirp
;
register struct mountlist
*mlp
, **mlpp
;
if (!strcmp(mlp
->ml_host
, hostp
) && !strcmp(mlp
->ml_dirp
, dirp
))
mlp
= (struct mountlist
*)malloc(sizeof (*mlp
));
strncpy(mlp
->ml_host
, hostp
, RPCMNT_NAMELEN
);
mlp
->ml_host
[RPCMNT_NAMELEN
] = '\0';
strncpy(mlp
->ml_dirp
, dirp
, RPCMNT_PATHLEN
);
mlp
->ml_dirp
[RPCMNT_PATHLEN
] = '\0';
mlp
->ml_next
= (struct mountlist
*)0;
if ((mlfile
= fopen(_PATH_RMOUNTLIST
, "a")) == NULL
) {
syslog(LOG_WARNING
, "Can't update %s", _PATH_RMOUNTLIST
);
fprintf(mlfile
, "%s %s\n", mlp
->ml_host
, mlp
->ml_dirp
);
* This function is called via. SIGTERM when the system is going down.
* It sends a broadcast RPCMNT_UMNTALL.
(void) clnt_broadcast(RPCPROG_MNT
, RPCMNT_VER1
, RPCMNT_UMNTALL
,
xdr_void
, (caddr_t
)0, xdr_void
, (caddr_t
)0, umntall_each
);
umntall_each(resultsp
, raddr
)
struct sockaddr_in
*raddr
;
* Free up an exports list component
register struct exportlist
*ep
;
register struct grouplist
*grp
;
register struct grouplist
*grp
;
if (grp
->type
== MNT_HOST
) {
if (grp
->gr_ptr
.gt_hostent
->h_name
) {
addrp
= grp
->gr_ptr
.gt_hostent
->h_addr_list
;
free((caddr_t
)grp
->gr_ptr
.gt_hostent
->h_addr_list
);
free(grp
->gr_ptr
.gt_hostent
->h_name
);
free((caddr_t
)grp
->gr_ptr
.gt_hostent
);
else if (grp
->type
== MNT_ISO
)
free((caddr_t
)grp
->gr_ptr
.gt_isoaddr
);
char *cp
, *endcp
, savedc
;
/* check to see if this group exists already */
if (strcmp(t_gn
->gn_name
,cp
) == 0) {
syslog(LOG_ERR
,"Group redifined, second ignored.");
/* make a new group list entry */
t_gn
= (struct groupnames
*)malloc(sizeof(struct groupnames
));
syslog(LOG_ERR
,"Group: Couldn't Malloc.");
strcpy(t_gn
->gn_name
,cp
);
t_gn
->gn_next
= grpnames
;
get_host(cp
, endcp
, ep
, &grp
);
grp
->gr_next
= t_gn
->gn_glist
;
get_host(cp
, endcp
, ep
, gp
)
register struct hostent
*hp
, *nhp
;
register struct grouplist
*grp
;
register char **addrp
, **naddrp
;
struct sockaddr_iso
*isoaddr
;
"Bad Exports File, %s: %s", cp
,
"inet_addr failed, ignored");
hp
->h_addrtype
= AF_INET
;
hp
->h_length
= sizeof (u_long
);
aptr
[0] = (char *)&saddr
;
} else if (!strncmp(cp
, "iso=", 4)) {
if ((isop
= iso_addr(cp
+ 4)) == NULL
) {
"Bad Exports File, %s: %s", cp
,
"iso_addr failed, ignored");
isoaddr
= (struct sockaddr_iso
*)
malloc(sizeof (struct sockaddr_iso
));
bzero((caddr_t
)isoaddr
, sizeof (struct sockaddr_iso
));
bcopy((caddr_t
)isop
, (caddr_t
)isoaddr
->siso_addr
,
sizeof (struct iso_addr
));
isoaddr
->siso_len
= sizeof (struct sockaddr_iso
);
isoaddr
->siso_family
= AF_ISO
;
grp
= (struct grouplist
*)
malloc(sizeof(struct grouplist
));
grp
->gr_ptr
.gt_isoaddr
= isoaddr
;
} else if ((hp
= gethostbyname(cp
)) == NULL
) {
syslog(LOG_ERR
, "Bad Exports File, %s: %s",
cp
, "Gethostbyname failed, ignored");
grp
= (struct grouplist
*)
malloc(sizeof(struct grouplist
));
nhp
= grp
->gr_ptr
.gt_hostent
= (struct hostent
*)
malloc(sizeof(struct hostent
));
bcopy((caddr_t
)hp
, (caddr_t
)nhp
,
i
= strlen(hp
->h_name
)+1;
nhp
->h_name
= (char *)malloc(i
);
bcopy(hp
->h_name
, nhp
->h_name
, i
);
naddrp
= nhp
->h_addr_list
= (char **)
malloc(i
*sizeof(char *));
syslog(LOG_ERR
, "No more memory: mountd Failed");
while((t_gn
!= NULL
) && !found
) {
if(strcmp(t_gn
->gn_name
,cp
) == 0) {
*gp
= (struct grouplist
*)
malloc(sizeof(struct grouplist
));
syslog(LOG_ERR
,"No more memory: mountd Failed");
(*gp
)->gr_ptr
.gt_grpname
= (struct groupnames
*)
malloc(sizeof(struct groupnames
));
if ((*gp
)->gr_ptr
.gt_grpname
== NULL
) {
syslog(LOG_ERR
,"No more memory: mountd Failed");
(*gp
)->gr_ptr
.gt_grpname
->gn_glist
= t_gn
->gn_glist
;
* char *realpath(const char *path, char resolved_path[MAXPATHLEN])
* find the real name of path, by removing all ".", ".."
* and symlink components.
* Jan-Simon Pendry, September 1991.
char resolved
[MAXPATHLEN
];
int d
= open(".", O_RDONLY
);
q
= strrchr(resolved
, '/');
while (q
> resolved
&& *q
== '/');
if (lstat(p
, &stb
) == 0) {
if (S_ISLNK(stb
.st_mode
)) {
int n
= readlink(p
, resolved
, MAXPATHLEN
);
if (S_ISDIR(stb
.st_mode
)) {
if (getcwd(resolved
, MAXPATHLEN
) == 0)
if (resolved
[0] == '/' && resolved
[1] == '\0')
if (strlen(resolved
) + strlen(wbuf
) + rootd
+ 1 > MAXPATHLEN
) {
SYSLOG(int pri
, const char *fmt
, ...)
vfprintf(stderr
, fmt
, ap
);