comparison contrib/chg/hgclient.c @ 28160:098cb7bd46a7

chg: forward umask from client to server This is necessary to make chg test pass on test-inherit-mode.t.
author Jun Wu <quark@fb.com>
date Mon, 15 Feb 2016 14:35:26 +0000
parents 726f8d6cc324
children c6e0c2533e5f
comparison
equal deleted inserted replaced
28159:d2d04d1d2f92 28160:098cb7bd46a7
31 /* cHg extension: */ 31 /* cHg extension: */
32 CAP_ATTACHIO = 0x0100, 32 CAP_ATTACHIO = 0x0100,
33 CAP_CHDIR = 0x0200, 33 CAP_CHDIR = 0x0200,
34 CAP_GETPAGER = 0x0400, 34 CAP_GETPAGER = 0x0400,
35 CAP_SETENV = 0x0800, 35 CAP_SETENV = 0x0800,
36 CAP_SETUMASK = 0x1000,
36 }; 37 };
37 38
38 typedef struct { 39 typedef struct {
39 const char *name; 40 const char *name;
40 unsigned int flag; 41 unsigned int flag;
45 {"runcommand", CAP_RUNCOMMAND}, 46 {"runcommand", CAP_RUNCOMMAND},
46 {"attachio", CAP_ATTACHIO}, 47 {"attachio", CAP_ATTACHIO},
47 {"chdir", CAP_CHDIR}, 48 {"chdir", CAP_CHDIR},
48 {"getpager", CAP_GETPAGER}, 49 {"getpager", CAP_GETPAGER},
49 {"setenv", CAP_SETENV}, 50 {"setenv", CAP_SETENV},
51 {"setumask", CAP_SETUMASK},
50 {NULL, 0}, /* terminator */ 52 {NULL, 0}, /* terminator */
51 }; 53 };
52 54
53 typedef struct { 55 typedef struct {
54 char ch; 56 char ch;
383 abortmsg("failed to getcwd (errno = %d)", errno); 385 abortmsg("failed to getcwd (errno = %d)", errno);
384 hgc->ctx.datasize = strlen(hgc->ctx.data); 386 hgc->ctx.datasize = strlen(hgc->ctx.data);
385 writeblockrequest(hgc, "chdir"); 387 writeblockrequest(hgc, "chdir");
386 } 388 }
387 389
390 static void forwardumask(hgclient_t *hgc)
391 {
392 mode_t mask = umask(0);
393 umask(mask);
394
395 static const char command[] = "setumask\n";
396 sendall(hgc->sockfd, command, sizeof(command) - 1);
397 uint32_t data = htonl(mask);
398 sendall(hgc->sockfd, &data, sizeof(data));
399 }
400
388 /*! 401 /*!
389 * Open connection to per-user cmdserver 402 * Open connection to per-user cmdserver
390 * 403 *
391 * If no background server running, returns NULL. 404 * If no background server running, returns NULL.
392 */ 405 */
431 abortmsg("insufficient capability: runcommand"); 444 abortmsg("insufficient capability: runcommand");
432 if (hgc->capflags & CAP_ATTACHIO) 445 if (hgc->capflags & CAP_ATTACHIO)
433 attachio(hgc); 446 attachio(hgc);
434 if (hgc->capflags & CAP_CHDIR) 447 if (hgc->capflags & CAP_CHDIR)
435 chdirtocwd(hgc); 448 chdirtocwd(hgc);
449 if (hgc->capflags & CAP_SETUMASK)
450 forwardumask(hgc);
436 451
437 return hgc; 452 return hgc;
438 } 453 }
439 454
440 /*! 455 /*!