osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subprocess svn checkout password issue


On 3/16/19 1:50 AM, Martin De Kauwe wrote:
> On Saturday, 16 March 2019 16:50:23 UTC+11, dieter  wrote:
>> Martin De Kauwe <mdekauwe at gmail.com> writes:
>> 
>> > I'm trying to write a script that will make a checkout from a svn repo and build the result for the user. However, when I attempt to interface with the shell it asks the user for their filename and I don't know how to capture this with my implementation. 

[...]

>> That is non-trivial.
>> 
>> Read the "svn" documentation. You might be able to pass in the
>> required information by other means, maybe an option, maybe
>> an envvar, maybe via a configuration file.
>> 
>> Otherwise, you must monitor what it written to the subprocess'
>> "stdout" and "stderr", recognized the interaction request
>> perform the interaction with the user and send the result
>> to the subprocess' stdin.
> 
> Thanks, I think this solution will work.
> 
> import subprocess
> import getpass
> 
> user = "XXX578"
> root="https://trac.nci.org.au/svn/cable";
> repo_name = "CMIP6-MOSRS"
> 
> pswd = "'" + getpass.getpass('Password:') + "'"
> cmd = "svn checkout %s/branches/Users/%s/%s --password %s" %\
>               (root, user, repo_name, pswd)

I'm not questioning whether or not that will work, but I will
point out that the password will be exposed to anyone doing a
process listing when that process is running (e.g., "ps -ef"
on a posix-like system).  This may or may not be an issue for
your use case.

> error = subprocess.call(cmd, shell=True)
> if error is 1:
>      raise("Error checking out repo")
>