2 * Copyright (c) 1999 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
12 ** The following test program tries the pathconf(2) routine. It should
13 ** be run in a non-NFS-mounted directory (e.g., /tmp) and on remote (NFS)
14 ** mounted directories running both NFS-v2 and NFS-v3 from systems that
15 ** both do and do not permit file giveaway.
18 #include <sys/types.h>
24 # undef EX_OK /* unistd.h may have another use for this */
29 static char id
[] = "@(#)$Id: t_pathconf.c,v 8.6 2001/09/23 03:35:41 ca Exp $";
44 printf("*** Run me as a non-root user! ***\n");
48 strcpy(tbuf
, "TXXXXXX");
52 printf("*** Could not create test file %s\n", tbuf
);
56 i
= pathconf(".", _PC_CHOWN_RESTRICTED
);
57 printf("pathconf(.) returns %2d, errno = %d\n", i
, errno
);
59 i
= pathconf(tbuf
, _PC_CHOWN_RESTRICTED
);
60 printf("pathconf(%s) returns %2d, errno = %d\n", tbuf
, i
, errno
);
62 i
= fpathconf(fd
, _PC_CHOWN_RESTRICTED
);
63 printf("fpathconf(%s) returns %2d, errno = %d\n", tbuf
, i
, errno
);
64 if (errno
== 0 && i
>= 0)
66 /* so it claims that it doesn't work -- try anyhow */
67 printf(" fpathconf claims that chown is safe ");
68 if (fchown(fd
, 1, 1) >= 0)
69 printf("*** but fchown works anyhow! ***\n");
71 printf("and fchown agrees\n");
75 /* well, let's see what really happens */
76 printf(" fpathconf claims that chown is not safe ");
77 if (fchown(fd
, 1, 1) >= 0)
78 printf("as indeed it is not\n");
80 printf("*** but in fact it is safe ***\n");