[BACK]Return to sock.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sndiod

Diff for /src/usr.bin/sndiod/sock.c between version 1.34 and 1.35

version 1.34, 2020/04/25 05:03:54 version 1.35, 2020/04/26 14:13:22
Line 15 
Line 15 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <sys/types.h>  #include <sys/types.h>
   #include <sys/socket.h>
 #include <netinet/in.h>  #include <netinet/in.h>
 #include <errno.h>  #include <errno.h>
 #include <poll.h>  #include <poll.h>
Line 150 
Line 151 
         }          }
 #endif  #endif
         if (f->pstate > SOCK_AUTH)          if (f->pstate > SOCK_AUTH)
                 sock_sesrefs--;                  sock_sesrefs -= f->sesrefs;
         if (f->slot) {          if (f->slot) {
                 slot_del(f->slot);                  slot_del(f->slot);
                 f->slot = NULL;                  f->slot = NULL;
Line 787 
Line 788 
 sock_auth(struct sock *f)  sock_auth(struct sock *f)
 {  {
         struct amsg_auth *p = &f->rmsg.u.auth;          struct amsg_auth *p = &f->rmsg.u.auth;
           uid_t euid;
           gid_t egid;
   
           /*
            * root bypasses any authenication checks and has no session
            */
           if (getpeereid(f->fd, &euid, &egid) == 0 && euid == 0) {
                   f->pstate = SOCK_HELLO;
                   f->sesrefs = 0;
                   return 1;
           }
   
         if (sock_sesrefs == 0) {          if (sock_sesrefs == 0) {
                 /* start a new session */                  /* start a new session */
                 memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN);                  memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN);
                   f->sesrefs = 1;
         } else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) {          } else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) {
                 /* another session is active, drop connection */                  /* another session is active, drop connection */
                 return 0;                  return 0;
         }          }
         sock_sesrefs++;          sock_sesrefs += f->sesrefs;
         f->pstate = SOCK_HELLO;          f->pstate = SOCK_HELLO;
         return 1;          return 1;
 }  }

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35