* If path doesn't end in /, return TRUE iff cmnd & path name the same inode;
* otherwise, return TRUE if cmnd names one of the inodes in path
*/
-int
-path_matches(cmnd, path)
+int path_matches(cmnd, path)
char *cmnd, *path;
{
int plen;
static char *c;
char *args;
+ /* don't bother with pseudo commands like "validate" */
+ if (*cmnd != '/')
+ return(FALSE);
+
/* only need to stat cmnd once since it never changes */
if (cmnd_st.st_dev == 0) {
if (stat(cmnd, &cmnd_st) < 0)
}
/* if the given path has command line args, split them out */
- if ((args = strchr(path, ' '))) {
+ if ((args = strchr(path, ' ')))
*args++ = '\0';
- }
plen = strlen(path);
if (path[plen - 1] != '/') {
if (stat(path, &pst) < 0)
return(FALSE);
- /* XXX - clean up this monstrosity! */
+ /* put things back the way we found 'em */
if (args)
*(args - 1) = ' ';
+ /*
+ * Return true if inode/device matches and there are no args
+ * (in sudoers or command) or if the args match;
+ * else return false.
+ */
if (cmnd_st.st_dev == pst.st_dev && cmnd_st.st_ino == pst.st_ino) {
if (!cmnd_args && !args)
return(TRUE);
return(FALSE);
}
- /* grot through path's directory entries, looking for cmnd */
+ /*
+ * Grot through path's directory entries, looking for cmnd.
+ */
dirp = opendir(path);
if (dirp == NULL)
return(FALSE);
-int
-addr_matches(n)
+int addr_matches(n)
char *n;
{
int i;
-int
-netgr_matches(netgr, host, user)
+int netgr_matches(netgr, host, user)
char *netgr;
char *host;
char *user;