Hi, Attached is the test code where fakeroot-hurd fails. fakeroot-hurd ./test_sockets bind: Operation not supported
Using fakeroot-tcp or no fakeroot succeeds: ./test_sockets Receiving via datagram socket plain (similar with fakeroot-tcp) ===== rpctrace ./test_sockets ... 67<--141(pid9219)->dir_unlink ("test_sockets_socket") = 0x40000002 (No such file or directory) task131(pid9219)->mach_port_deallocate (pn{ 5}) = 0 task131(pid9219)->vm_allocate (17189648 4096 1) = 0 16957440 109<--142(pid9219)->dir_lookup ("servers/socket/1" 0 0) = 0 1 "" 158<--157(pid9219) 158<--157(pid9219)->socket_create (2 0) = 0 160<--159(pid9219) task131(pid9219)->mach_port_mod_refs (pn{ 5} 0 1) = 0 67<--141(pid9219)->dir_mkfile (16 438) = 0 162<--161(pid9219) 162<--161(pid9219)->file_set_translator (6 6 0 "/hurd/ifsock" (null)) = 0 162<--161(pid9219)->dir_lookup ("" 0 0) = 0 1 "" 164<--163(pid9219) 164<--163(pid9219)->ifsock_getsockaddr () = 0 166<--165(pid9219) 162<--161(pid9219)->file_chmod (420) = 0 67<--141(pid9219)->dir_link ( 162<--161(pid9219) "test_sockets_socket" 1) = 0 task131(pid9219)->mach_port_deallocate (pn{ 21}) = 0 task131(pid9219)->mach_port_deallocate (pn{ 20}) = 0 task131(pid9219)->mach_port_deallocate (pn{ 5}) = 0 160<--159(pid9219)->socket_bind ( 166<--165(pid9219)) = 0 task131(pid9219)->mach_port_deallocate (pn{ 22}) = 0 67<--141(pid9219)->dir_lookup ("test_sockets_socket" 0 0) = 0 1 "" 166<--167(pid9219) 166<--167(pid9219)->file_chmod (292) = 0 task131(pid9219)->mach_port_deallocate (pn{ 22}) = 0 156<--155(pid9219)->io_write ("Receiving via datagram socket\n" -1)Receiving via datagram socket = 0 30 140<--144(pid9219)->proc_mark_exit_request (0 0) = 0 task131(pid9219)->task_terminate () = 0 Child 9219 exited with 0 fakeroot-hurd ============= fakeroot-hurd rpctrace ./test_sockets 10<--46(pid9244)->dir_unlink ("test_sockets_socket") = 0x40000002 (No such file or directory) task34(pid9244)->mach_port_deallocate (pn{ 7}) = 0 task34(pid9244)->vm_allocate (17189648 4096 1) = 0 16957440 9<--47(pid9244)->dir_lookup ("servers/socket/1" 0 0) = 0 1 "" 63<--62(pid9244) 63<--62(pid9244)->socket_create (2 0) = 0 65<--64(pid9244) task34(pid9244)->mach_port_mod_refs (pn{ 7} 0 1) = 0 10<--46(pid9244)->dir_mkfile (16 438) = 0 67<--66(pid9244) 67<--66(pid9244)->file_set_translator (6 6 0 "/hurd/ifsock" (null)) = 0x4000002d (Operation not supported) task34(pid9244)->mach_port_deallocate (pn{ 22}) = 0 task34(pid9244)->mach_port_deallocate (pn{ 7}) = 0 task34(pid9244)->mach_port_deallocate (pn{ 21}) = 0 task34(pid9244)->mach_port_mod_refs (pn{ 6} 0 1) = 0 task34(pid9244)->mach_port_mod_refs (pn{ 19} 0 1) = 0 11<--45(pid9244)->io_get_openmodes () = 0 259 11<--45(pid9244)->io_stat () = 0 {14 999 0 0 0 1368812073 0 8397200 1 1000 5 0 0 1430739968 0 1430739968 0 1430739968 0 512 8 0 0 0 0 0 0 0 0 0 0 0} 11<--45(pid9244)->io_seek (0 1) = 0x4000001d (Illegal seek) 61<--60(pid9244)->io_write ("bind: Operation not supported\n" -1)bind: Operation not supported = 0 30 task34(pid9244)->mach_port_deallocate (pn{ 19}) = 0 task34(pid9244)->mach_port_deallocate (pn{ 6}) = 0 43<--49(pid9244)->proc_mark_exit_request (256 0) = 0 task34(pid9244)->task_terminate () = 0 Child 9244 exited with 1 ./my_fakeroot-hurd rpctrace ./test_sockets With original code in trans/fakeroot.c: netfs_attempt_chmod (struct iouser *cred, struct node *np, mode_t mode) { if ((mode & S_IFMT) == 0) mode |= np->nn_stat.st_mode & S_IFMT; if ((mode & S_IFMT) != (np->nn_stat.st_mode & S_IFMT)) return EOPNOTSUPP; <<<- Errors out here ->>> /* We don't bother with error checking since the fake mode change should always succeed--worst case a later open will get EACCES. */ (void) file_chmod (netfs_node_netnode (np)->file, mode); set_faked_attribute (np, FAKE_MODE); np->nn_stat.st_mode = mode; return 0; } With modifications to handle the socket case: (and printouts in netfs_S_dir_lookup()) ... if ((mode & S_IFMT) == 0) { mode |= np->nn_stat.st_mode & S_IFMT; /* We don't bother with error checking since the fake mode change should always succeed--worst case a later open will get EACCES. */ (void) file_chmod (netfs_node_netnode (np)->file, mode); set_faked_attribute (np, FAKE_MODE); np->nn_stat.st_mode = mode; } if ((mode & S_IFMT) != 0) { fprintf(stderr,"trans/fakeroot.c: netfs_attempt_chmod: mode=%0o \n", mode)\ ; fprintf(stderr,"trans/fakeroot.c: netfs_attempt_chmod: (mode&S_IFMT)=%0o,\ S_IFSOCK=%0o\n", (mode & S_IFMT), S_IFSOCK); fprintf(stderr,"trans/fakeroot.c: netfs_attempt_chmod: np->nn_stat.st_mod\ e=%0o, (np->nn_stat.st_mode & S_IFMT)=%0o\n", np->nn_stat.st_mode, (np->nn_stat\ .st_mode & S_IFMT)); fflush(stderr); if ((mode & S_IFMT) != (np->nn_stat.st_mode & S_IFMT)) { switch (mode & S_IFMT) { ... case S_IFSOCK: fprintf(stderr, "case S_IFSOCK\n"); fflush(stderr); np->nn_stat.st_mode = mode; break; ... fakeroot-hurd rpctrace ./test_sockets ... 10<--46(pid9260)->dir_unlink ("test_sockets_socket") = 0x40000002 (No such file or directory) task34(pid9260)->mach_port_deallocate (pn{ 7}) = 0 task34(pid9260)->vm_allocate (17189648 4096 1) = 0 16957440 9<--47(pid9260)->dir_lookup ("servers/socket/1" 0 0) trans_fakeroot.c:netfs_S_dir_lookup: calling dir_lookup: dir=26, filename='servers/socket/1', mode=0 trans_fakeroot.c:netfs_S_dir_lookup: BEFORE switch *do_retry: *do_retry=1, retry_name='', file=60, err=0 = 0 1 "" 63<--62(pid9260) 63<--62(pid9260)->socket_create (2 0) = 0 65<--64(pid9260) task34(pid9260)->mach_port_mod_refs (pn{ 7} 0 1) = 0 10<--46(pid9260)->dir_mkfile (16 438)trans/fakeroot.c:netfs_attempt_mkfile: BEFORE dir_mkfile: real_mode=666, mode=666 trans/fakeroot.c:netfs_attempt_mkfile: AFTER dir_mkfile: new_file=54 = 0 67<--66(pid9260) 67<--66(pid9260)->file_set_translator (6 6 0 "/hurd/ifsock" (null))trans/fakeroot.c: netfs_attempt_chmod: mode=140666 trans/fakeroot.c: netfs_attempt_chmod: (mode&S_IFMT)=140000, S_IFSOCK=140000 trans/fakeroot.c: netfs_attempt_chmod: np->nn_stat.st_mode=100666, (np->nn_stat.st_mode & S_IFMT)=100000 case S_IFSOCK = 0 67<--66(pid9260)->dir_lookup ("" 0 0) trans_fakeroot.c:netfs_S_dir_lookup: calling dir_lookup: dir=54, filename='', mode=0 trans_fakeroot.c:netfs_S_dir_lookup: BEFORE switch *do_retry: *do_retry=1, retry_name='', file=59, err=0 = 0 1 "" 69<--68(pid9260) 69<--68(pid9260)->ifsock_getsockaddr () = 0x4000002d (Operation not supported) task34(pid9260)->mach_port_deallocate (pn{ 23}) = 0 task34(pid9260)->mach_port_deallocate (pn{ 22}) = 0 task34(pid9260)->mach_port_deallocate (pn{ 7}) = 0 task34(pid9260)->mach_port_deallocate (pn{ 21}) = 0 task34(pid9260)->mach_port_mod_refs (pn{ 6} 0 1) = 0 task34(pid9260)->mach_port_mod_refs (pn{ 19} 0 1) = 0 11<--45(pid9260)->io_get_openmodes () = 0 259 11<--45(pid9260)->io_stat () = 0 {14 999 0 0 0 1368812073 0 8397200 1 1000 5 0 0 1430740200 0 1430740200 0 1430740200 0 512 8 0 0 0 0 0 0 0 0 0 0 0} 11<--45(pid9260)->io_seek (0 1) = 0x4000001d (Illegal seek) 61<--60(pid9260)->io_write ("bind: Gratuitous error\n" -1)bind: Gratuitous error = 0 23 task34(pid9260)->mach_port_deallocate (pn{ 19}) = 0 task34(pid9260)->mach_port_deallocate (pn{ 6}) = 0 43<--49(pid9260)->proc_mark_exit_request (256 0) = 0 task34(pid9260)->task_terminate () = 0 Child 9260 exited with 1
/* test_sockets.c */ #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> #include <fcntl.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <errno.h> typedef enum { FALSE, TRUE } Boolean; #define SOCK_PATH "test_sockets_socket" #define USE_SOCK_DGRAM //#undef USE_SOCK_DGRAM #define handle_error(msg) \ do { perror(msg); exit(EXIT_FAILURE); } while (0) int main(int argc, char *argv[]) { struct sockaddr_un addr = { 0 }; const char *path = SOCK_PATH; #ifdef USE_SOCK_DGRAM int sfd; int type = SOCK_DGRAM; #else int sfd, cfd; int type = SOCK_STREAM; #define LISTEN_BACKLOG 50 struct sockaddr_un peer_addr = { 0 }; socklen_t peer_addr_size; #endif /* Create a UNIX domain socket and bind it to 'path'. Return the socket descriptor on success, or -1 on error. */ /* Create socket bound to well-known address */ if (remove(SOCK_PATH) == -1 && errno != ENOENT) handle_error("remove-SOCK_PATH"); addr.sun_family = AF_UNIX; if (strlen(path) < sizeof(addr.sun_path)) strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); else handle_error("strncpy"); sfd = socket(AF_UNIX, type, 0); if (sfd == -1) handle_error("socket"); if (bind(sfd, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) == -1) { close(sfd); handle_error("bind"); } /* Temporary test: make socket world readable */ //Does not work? chmod (path, S_IRUSR || S_IWUSR || S_IROTH || S_IWOTH); chmod (path, 0444); //chmod (path, 0644); //chmod (path, 0666); #ifdef USE_SOCK_DGRAM fprintf(stderr, "Receiving via datagram socket\n"); #else fprintf(stderr, "Receiving via stream socket\n"); if (listen(sfd, LISTEN_BACKLOG) == -1) handle_error("listen"); peer_addr_size = sizeof(struct sockaddr_un); cfd = accept(sfd, (struct sockaddr *) &peer_addr, &peer_addr_size); if (cfd == -1) handle_error("accept"); #endif exit(EXIT_SUCCESS); }