mirror of
https://github.com/sheumann/hush.git
synced 2024-12-28 07:30:23 +00:00
fuser: fix vda's breakage: DOH! chdir'ing to /proc breaks relative paths
This commit is contained in:
parent
f2f3868e0d
commit
1b2058fe98
@ -57,11 +57,11 @@ static int file_to_dev_inode(const char *filename, dev_t *dev, ino_t *inode)
|
|||||||
|
|
||||||
static char *parse_net_arg(const char *arg, unsigned *port)
|
static char *parse_net_arg(const char *arg, unsigned *port)
|
||||||
{
|
{
|
||||||
char path[12], tproto[5];
|
char path[20], tproto[5];
|
||||||
|
|
||||||
if (sscanf(arg, "%u/%4s", port, tproto) != 2)
|
if (sscanf(arg, "%u/%4s", port, tproto) != 2)
|
||||||
return NULL;
|
return NULL;
|
||||||
sprintf(path, "net/%s", tproto);
|
sprintf(path, "/proc/net/%s", tproto);
|
||||||
if (access(path, R_OK) != 0)
|
if (access(path, R_OK) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return xstrdup(tproto);
|
return xstrdup(tproto);
|
||||||
@ -99,7 +99,7 @@ static inode_list *add_inode(inode_list *ilist, dev_t dev, ino_t inode)
|
|||||||
static inode_list *scan_proc_net(const char *proto,
|
static inode_list *scan_proc_net(const char *proto,
|
||||||
unsigned port, inode_list *ilist)
|
unsigned port, inode_list *ilist)
|
||||||
{
|
{
|
||||||
char path[12], line[MAX_LINE + 1];
|
char path[20], line[MAX_LINE + 1];
|
||||||
char addr[128];
|
char addr[128];
|
||||||
ino_t tmp_inode;
|
ino_t tmp_inode;
|
||||||
dev_t tmp_dev;
|
dev_t tmp_dev;
|
||||||
@ -109,7 +109,7 @@ static inode_list *scan_proc_net(const char *proto,
|
|||||||
|
|
||||||
tmp_dev = find_socket_dev();
|
tmp_dev = find_socket_dev();
|
||||||
|
|
||||||
sprintf(path, "net/%s", proto);
|
sprintf(path, "/proc/net/%s", proto);
|
||||||
f = fopen(path, "r");
|
f = fopen(path, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return ilist;
|
return ilist;
|
||||||
@ -314,8 +314,6 @@ Find processes which use FILEs or PORTs
|
|||||||
opt = getopt32(argv, OPTION_STRING);
|
opt = getopt32(argv, OPTION_STRING);
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
xchdir("/proc");
|
|
||||||
|
|
||||||
ilist = NULL;
|
ilist = NULL;
|
||||||
pp = argv;
|
pp = argv;
|
||||||
while (*pp) {
|
while (*pp) {
|
||||||
|
Loading…
Reference in New Issue
Block a user