Changeset 629
- Timestamp:
- 10/16/07 01:13:43 (1 year ago)
- Files:
-
- trunk/server/ChangeLog (modified) (1 diff)
- trunk/server/doc/memcached.1 (modified) (1 diff)
- trunk/server/memcached.c (modified) (7 diffs)
- trunk/server/memcached.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/server/ChangeLog
r627 r629 1 2007-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 1 8 2007-10-03 Paul Lindner <lindner@inuus.com> 2 9 * Incorporate "cas" operation developed by Dustin trunk/server/doc/memcached.1
r606 r629 23 23 .B \-s <file> 24 24 Unix socket path to listen on (disables network support). 25 .TP 26 .B \-a <perms> 27 Permissions (in octal format) for Unix socket created with -s option. 25 28 .TP 26 29 .B \-l <ip_addr> trunk/server/memcached.c
r627 r629 165 165 166 166 static void settings_init(void) { 167 settings.access=0700; 167 168 settings.port = 11211; 168 169 settings.udpport = 0; … … 761 762 memcpy(ITEM_data(new_it) + old_it->nbytes - 2 /* CRLF */, ITEM_data(it), it->nbytes); 762 763 } else { 763 /* NREAD_PREPEND */ 764 /* NREAD_PREPEND */ 764 765 memcpy(ITEM_data(new_it), ITEM_data(it), it->nbytes); 765 766 memcpy(ITEM_data(new_it) + it->nbytes - 2 /* CRLF */, ITEM_data(old_it), old_it->nbytes); … … 2279 2280 } 2280 2281 2281 static int server_socket_unix(const char *path ) {2282 static int server_socket_unix(const char *path, int access_mask) { 2282 2283 int sfd; 2283 2284 struct linger ling = {0, 0}; … … 2285 2286 struct stat tstat; 2286 2287 int flags =1; 2288 int old_umask; 2287 2289 2288 2290 if (!path) { … … 2314 2316 addr.sun_family = AF_UNIX; 2315 2317 strcpy(addr.sun_path, path); 2318 old_umask=umask( ~(access_mask&0777)); 2316 2319 if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { 2317 2320 perror("bind()"); 2318 2321 close(sfd); 2322 umask(old_umask); 2319 2323 return -1; 2320 2324 } 2325 umask(old_umask); 2321 2326 if (listen(sfd, 1024) == -1) { 2322 2327 perror("listen()"); … … 2568 2573 2569 2574 /* 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) { 2571 2576 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 2572 2582 case 'U': 2573 2583 settings.udpport = atoi(optarg); … … 2747 2757 /* create unix mode sockets after dropping privileges */ 2748 2758 if (settings.socketpath != NULL) { 2749 l_socket = server_socket_unix(settings.socketpath );2759 l_socket = server_socket_unix(settings.socketpath,settings.access); 2750 2760 if (l_socket == -1) { 2751 2761 fprintf(stderr, "failed to listen\n"); trunk/server/memcached.h
r627 r629 84 84 int evict_to_free; 85 85 char *socketpath; /* path to unix socket if using local socket */ 86 int access; /* access mask (a la chmod) for unix domain socket */ 86 87 double factor; /* chunk size growth factor */ 87 88 int chunk_size;
