Mercurial > hg
changeset 40108:e5fbdc3659fc
chgserver: add "setumask2" command which uses correct message frame
The first 4 bytes should be a length field, not a value. Spotted while
porting chg functions to the Rust one.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 04 Oct 2018 23:25:55 +0900 |
parents | 212a52d8e9d8 |
children | 413b6b10fdd5 |
files | mercurial/chgserver.py |
diffstat | 1 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/chgserver.py Tue Oct 09 22:29:10 2018 +0200 +++ b/mercurial/chgserver.py Thu Oct 04 23:25:55 2018 +0900 @@ -19,7 +19,8 @@ 'setenv' command replace os.environ completely -'setumask' command +'setumask' command (DEPRECATED) +'setumask2' command set umask 'validate' command @@ -452,8 +453,20 @@ os.chdir(path) def setumask(self): + """Change umask (DEPRECATED)""" + # BUG: this does not follow the message frame structure, but kept for + # backward compatibility with old chg clients for some time + self._setumask(self._read(4)) + + def setumask2(self): """Change umask""" - mask = struct.unpack('>I', self._read(4))[0] + data = self._readstr() + if len(data) != 4: + raise ValueError('invalid mask length in setumask2 request') + self._setumask(data) + + def _setumask(self, data): + mask = struct.unpack('>I', data)[0] _log('setumask %r\n' % mask) os.umask(mask) @@ -488,7 +501,8 @@ 'chdir': chdir, 'runcommand': runcommand, 'setenv': setenv, - 'setumask': setumask}) + 'setumask': setumask, + 'setumask2': setumask2}) if util.safehasattr(procutil, 'setprocname'): def setprocname(self):