Changeset 3713:38a2d99a3bed in roaraudio for roard/clients.c


Ignore:
Timestamp:
04/25/10 04:24:59 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

moved socket cred things out of the network.c into the clients.c/client_set_fh()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r3684 r3713  
    132132 
    133133int clients_set_fh    (int id, int    fh) { 
    134  
    135  if ( g_clients[id] == NULL ) 
    136   return -1; 
    137  
    138  g_clients[id]->fh = fh; 
     134 struct roar_client * c; 
     135#ifdef SO_PEERCRED 
     136 struct ucred cred; 
     137 socklen_t cred_len = sizeof(cred); 
     138#endif 
     139 
     140 if ( (c = g_clients[id]) == NULL ) 
     141  return -1; 
     142 
     143 c->fh = fh; 
     144 
     145#ifdef SO_PEERCRED 
     146 if (getsockopt(fh, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len) != -1) { 
     147  if ( cred.pid != 0 ) { 
     148   c->pid = cred.pid; 
     149   c->uid = cred.uid; 
     150   c->gid = cred.gid; 
     151  } 
     152 } else { 
     153  ROAR_DBG("req_on_identify(): Can't get creds via SO_PEERCRED: %s", strerror(errno)); 
     154 } 
     155#elif defined(ROAR_HAVE_GETPEEREID) 
     156 if (getpeereid(fh, &(c->uid), &(c->gid)) == -1) { 
     157  ROAR_DBG("req_on_identify(): Can't get creds via getpeereid(): %s", strerror(errno)); 
     158 } 
     159#endif 
    139160 
    140161 return 0; 
Note: See TracChangeset for help on using the changeset viewer.