diff options
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/dial.c | 3 | ||||
-rw-r--r-- | src/lib9/netmkaddr.c | 30 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/lib9/dial.c b/src/lib9/dial.c index dcbdc0b8..88dcf564 100644 --- a/src/lib9/dial.c +++ b/src/lib9/dial.c @@ -118,6 +118,9 @@ Unix: free(buf); return -1; } + /* Allow regular files in addition to Unix sockets. */ + if((s = open(unix, ORDWR)) >= 0) + return s; memset(&su, 0, sizeof su); su.sun_family = AF_UNIX; if(strlen(unix)+1 > sizeof su.sun_path){ diff --git a/src/lib9/netmkaddr.c b/src/lib9/netmkaddr.c index fd53f468..b476516d 100644 --- a/src/lib9/netmkaddr.c +++ b/src/lib9/netmkaddr.c @@ -16,21 +16,25 @@ netmkaddr(char *linear, char *defnet, char *defsrv) */ cp = strchr(linear, '!'); if(cp == 0){ - if(defnet==0){ - if(defsrv) - snprint(addr, sizeof(addr), "net!%s!%s", - linear, defsrv); - else - snprint(addr, sizeof(addr), "net!%s", linear); + if(defnet == 0) + defnet = "net"; + /* allow unix sockets to omit unix! prefix */ + if(access(linear, 0) >= 0){ + snprint(addr, sizeof(addr), "unix!%s", linear); + return addr; } - else { - if(defsrv) - snprint(addr, sizeof(addr), "%s!%s!%s", defnet, - linear, defsrv); - else - snprint(addr, sizeof(addr), "%s!%s", defnet, - linear); + /* allow host:service in deference to Unix convention */ + if((cp = strchr(linear, ':')) != nil){ + snprint(addr, sizeof(addr), "%s!%.*s!%s", + defnet, utfnlen(linear, cp-linear), + linear, cp+1); + return addr; } + if(defsrv) + snprint(addr, sizeof(addr), "%s!%s!%s", + defnet, linear, defsrv); + else + snprint(addr, sizeof(addr), "%s!%s", defnet, linear); return addr; } |