|
Server IP : 192.168.23.10 / Your IP : 216.73.216.47 Web Server : Apache System : Linux echo.premieradvertising.com 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 7 14:54:22 EST 2023 x86_64 User : rrrallyteam ( 1049) PHP Version : 8.1.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF Directory (0755) : /usr/local/../share/libtool/../ruby/../doc/perl-HTTP-Message/../rsync/support/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
#!/usr/bin/env python3
# This implements a simple protocol to do user & group conversions between
# names & ids. All input and output consists of simple strings with a
# terminating newline.
#
# The requests can be:
#
# uid ID_NUM\n -> NAME\n
# gid ID_NUM\n -> NAME\n
# usr NAME\n -> ID_NUM\n
# grp NAME\n -> ID_NUM\n
#
# An unknown ID_NUM or NAME results in an empty return value.
#
# This is used by an rsync daemon when configured with the "name converter" and
# (often) "use chroot = true". While this converter uses real user & group
# lookups you could change it to use any mapping idiom you'd like.
import sys, argparse, pwd, grp
def main():
for line in sys.stdin:
try:
req, arg = line.rstrip().split(' ', 1)
except:
req = None
try:
if req == 'uid':
ans = pwd.getpwuid(int(arg)).pw_name
elif req == 'gid':
ans = grp.getgrgid(int(arg)).gr_name
elif req == 'usr':
ans = pwd.getpwnam(arg).pw_uid
elif req == 'grp':
ans = grp.getgrnam(arg).gr_gid
else:
print("Invalid request", file=sys.stderr)
sys.exit(1)
except KeyError:
ans = ''
print(ans, flush=True)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Convert users & groups between names & numbers for an rsync daemon.")
args = parser.parse_args()
main()
# vim: sw=4 et