Changeset 60:d1fa94aadc08 in roaraudio
- Timestamp:
- 07/12/08 12:19:08 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
include/roaraudio.h
r57 r60 12 12 #include <limits.h> 13 13 #include <sys/mman.h> 14 15 // TODO: can we move the next block into roard specific includes? 16 #include <grp.h> 17 #include <pwd.h> 18 #include <sys/stat.h> 14 19 15 20 #include <arpa/inet.h> -
libroar/socket.c
r2 r60 65 65 int fh; 66 66 struct sockaddr_in socket_addr; 67 struct sockaddr_un socket_addr_un; 67 68 struct hostent * he; 68 69 //unsigned int host_div = 0; … … 82 83 type == ROAR_SOCKET_TYPE_UNIX ? "UNIX" : "INET", host, port); 83 84 84 memset(&socket_addr, 0, sizeof(socket_addr)); 85 memset(&he, 0, sizeof(he)); 85 memset(&socket_addr , 0, sizeof(socket_addr)); 86 memset(&socket_addr_un, 0, sizeof(socket_addr_un)); 87 memset(&he, 0, sizeof(he)); // FIXME: we have a valid pointer in here???? 86 88 87 89 … … 109 111 // hey! we have a socket... 110 112 } else { 113 socket_addr_un.sun_family = AF_UNIX; 114 strncpy(socket_addr_un.sun_path, host, sizeof(socket_addr_un.sun_path) - 1); 115 111 116 fh = roar_socket_new_unix(); 112 close(fh); 113 return -1; 117 118 if ( mode_func(fh, (struct sockaddr *)&socket_addr_un, sizeof(struct sockaddr_un)) == -1 ) { 119 ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno)); 120 close(fh); 121 return -1; 122 } 114 123 } 115 124 -
roard/roard.c
r44 r60 2 2 3 3 #include "roard.h" 4 5 char * server = ROAR_DEFAULT_SOCK_GLOBAL; // global server address 4 6 5 7 void usage (void) { … … 32 34 " -b --bind - IP/Hostname to bind to\n" 33 35 " -s --sock - Filename for UNIX Domain Socket\n" 36 " -G GROUP - Sets the group for the UNIX Domain Socket, (default: audio)\n" 37 " You need the permittions to change the GID\n" 34 38 ); 35 39 // printf("\n Options:\n\n"); … … 40 44 int i; 41 45 char * k; 46 char user_sock[80] = {0}; 42 47 struct roar_audio_info sa; 43 48 char * driver = NULL; 44 49 char * device = NULL; 45 50 char * opts = NULL; 46 char * server = ROAR_DEFAULT_HOST;51 // char * server = ROAR_DEFAULT_SOCK_GLOBAL; 47 52 int port = ROAR_DEFAULT_PORT; 48 53 int drvid; … … 51 56 char * s_opt = NULL; 52 57 int s_prim = 0; 58 char * sock_grp = "audio"; 59 struct group * grp; 53 60 DRIVER_USERDATA_T drvinst; 54 61 struct roar_client * self = NULL; … … 63 70 64 71 g_sa = &sa; 72 73 74 if ( getuid() != 0 && getenv("HOME") ) { 75 snprintf(user_sock, 79, "%s/%s", getenv("HOME"), ROAR_DEFAULT_SOCK_USER); 76 server = user_sock; 77 } 65 78 66 79 if ( sources_init() == -1 ) { … … 113 126 } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 ) { 114 127 server = argv[++i]; 128 } else if ( strcmp(k, "-G") == 0 ) { 129 sock_grp = argv[++i]; 115 130 116 131 } else { … … 128 143 } 129 144 145 if ( *server == '/' ) { 146 if ( (grp = getgrnam(sock_grp)) == NULL ) { 147 ROAR_ERR("Can not get GID for group %s: %s", sock_grp, strerror(errno)); 148 } else { 149 chown(server, -1, grp->gr_gid); 150 if ( getuid() == 0 ) 151 chmod(server, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); 152 } 153 } 154 130 155 if ( output_buffer_init(&sa) == -1 ) { 131 156 ROAR_ERR("Can not init output buffer!"); … … 185 210 void clean_quit_prep (void) { 186 211 close(g_listen_socket); 212 213 if ( *server == '/' ) 214 unlink(server); 215 216 187 217 sources_free(); 188 218 streams_free();
Note: See TracChangeset
for help on using the changeset viewer.