Changeset 629

Show
Ignore:
Timestamp:
10/16/07 01:13:43 (1 year ago)
Author:
plindner
Message:

Patch from David Bremner <bremner@unb.ca> that implements a new option "-a"
which takes an octal permission mask (like chmod) sets the permissions
on the unix domain socket (specified by "-s").

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/server/ChangeLog

    r627 r629  
     12007-10-15  Paul Lindner  <lindner@inuus.com> 
     2 
     3        * Patch from David Bremner <bremner@unb.ca> that implements 
     4          a new option "-a" which takes an octal permission mask 
     5          (like chmod) sets the permissions on the unix domain socket  
     6          (specified by "-s"). 
     7 
    182007-10-03 Paul Lindner <lindner@inuus.com> 
    29        * Incorporate "cas" operation developed by Dustin 
  • trunk/server/doc/memcached.1

    r606 r629  
    2323.B \-s <file> 
    2424Unix socket path to listen on (disables network support). 
     25.TP 
     26.B \-a <perms> 
     27Permissions (in octal format) for Unix socket created with -s option. 
    2528.TP 
    2629.B \-l <ip_addr>   
  • trunk/server/memcached.c

    r627 r629  
    165165 
    166166static void settings_init(void) { 
     167    settings.access=0700; 
    167168    settings.port = 11211; 
    168169    settings.udpport = 0; 
     
    761762                memcpy(ITEM_data(new_it) + old_it->nbytes - 2 /* CRLF */, ITEM_data(it), it->nbytes); 
    762763            } else { 
    763                 /* NREAD_PREPEND */  
     764                /* NREAD_PREPEND */ 
    764765                memcpy(ITEM_data(new_it), ITEM_data(it), it->nbytes); 
    765766                memcpy(ITEM_data(new_it) + it->nbytes - 2 /* CRLF */, ITEM_data(old_it), old_it->nbytes); 
     
    22792280} 
    22802281 
    2281 static int server_socket_unix(const char *path) { 
     2282static int server_socket_unix(const char *path, int access_mask) { 
    22822283    int sfd; 
    22832284    struct linger ling = {0, 0}; 
     
    22852286    struct stat tstat; 
    22862287    int flags =1; 
     2288    int old_umask; 
    22872289 
    22882290    if (!path) { 
     
    23142316    addr.sun_family = AF_UNIX; 
    23152317    strcpy(addr.sun_path, path); 
     2318    old_umask=umask( ~(access_mask&0777)); 
    23162319    if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { 
    23172320        perror("bind()"); 
    23182321        close(sfd); 
     2322        umask(old_umask); 
    23192323        return -1; 
    23202324    } 
     2325    umask(old_umask); 
    23212326    if (listen(sfd, 1024) == -1) { 
    23222327        perror("listen()"); 
     
    25682573 
    25692574    /* process arguments */ 
    2570     while ((c = getopt(argc, argv, "bp:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:")) != -1) { 
     2575    while ((c = getopt(argc, argv, "a:bp:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:")) != -1) { 
    25712576        switch (c) { 
     2577        case 'a': 
     2578            /* access for unix domain socket, as octal mask (like chmod)*/ 
     2579            settings.access= strtol(optarg,NULL,8); 
     2580            break; 
     2581 
    25722582        case 'U': 
    25732583            settings.udpport = atoi(optarg); 
     
    27472757    /* create unix mode sockets after dropping privileges */ 
    27482758    if (settings.socketpath != NULL) { 
    2749         l_socket = server_socket_unix(settings.socketpath); 
     2759        l_socket = server_socket_unix(settings.socketpath,settings.access); 
    27502760        if (l_socket == -1) { 
    27512761            fprintf(stderr, "failed to listen\n"); 
  • trunk/server/memcached.h

    r627 r629  
    8484    int evict_to_free; 
    8585    char *socketpath;   /* path to unix socket if using local socket */ 
     86    int access;  /* access mask (a la chmod) for unix domain socket */ 
    8687    double factor;          /* chunk size growth factor */ 
    8788    int chunk_size;