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

Diff for /src/usr.bin/aucat/Attic/sock.c between version 1.43 and 1.44

version 1.43, 2010/04/21 06:13:07 version 1.44, 2010/04/22 17:43:30
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/socket.h>
   #include <unistd.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 35 
Line 38 
 int sock_write(struct sock *);  int sock_write(struct sock *);
 int sock_execmsg(struct sock *);  int sock_execmsg(struct sock *);
 void sock_reset(struct sock *);  void sock_reset(struct sock *);
   void sock_close(struct file *);
   
 struct fileops sock_ops = {  struct fileops sock_ops = {
         "sock",          "sock",
         sizeof(struct sock),          sizeof(struct sock),
         pipe_close,          sock_close,
         pipe_read,          pipe_read,
         pipe_write,          pipe_write,
         NULL, /* start */          NULL, /* start */
Line 83 
Line 87 
         sock_locreq          sock_locreq
 };  };
   
   unsigned sock_sesrefs = 0;      /* connections to the session */
   uid_t sock_sesuid;              /* owner of the session */
   
 void  void
   sock_close(struct file *f)
   {
           sock_sesrefs--;
           pipe_close(f);
   }
   
   void
 rsock_done(struct aproc *p)  rsock_done(struct aproc *p)
 {  {
         struct sock *f = (struct sock *)p->u.io.file;          struct sock *f = (struct sock *)p->u.io.file;
Line 296 
Line 310 
 {  {
         struct aproc *rproc, *wproc;          struct aproc *rproc, *wproc;
         struct sock *f;          struct sock *f;
           uid_t uid, gid;
   
           /*
            * ensure that all connections belong to the same user,
            * for privacy reasons.
            *
            * XXX: is there a portable way of doing this ?
            */
           if (getpeereid(fd, &uid, &gid) < 0) {
                   close(fd);
                   return NULL;
           }
           if (sock_sesrefs == 0) {
                   /* start a new session */
                   sock_sesuid = uid;
           } else if (uid != sock_sesuid) {
                   /* session owned by another user, drop connection */
                   close(fd);
                   return NULL;
           }
           sock_sesrefs++;
   
         f = (struct sock *)pipe_new(ops, fd, "sock");          f = (struct sock *)pipe_new(ops, fd, "sock");
         if (f == NULL)          if (f == NULL)

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44