Change Accurev Workspace Owner - accurev

I'm trying to transfer a workspace to another user.
Is there a way to change the owner of a workspace in accurev?

The Manual Way
As User1:
The first mkws command was done at some point in the past to initially create the workspace. The `chws' command is just taking the workspace and dumping it to an arbitrary place.
accurev login User1 User1Password
accurev mkws -w wkspace_name -b backing_stream -l /wkspaces/wkspace_original_location
accurev chws -w wkspace_name -l /wkspaces/temp_location_one
As User2:
accurev login User2 User2Password
accurev mkws -w wkspace_name -b backing_stream -l /wkspaces/temp_location_two
accurev chws -w wkspace_name -l /wkspacees/wkspace_original_location
I had to go to lunch to come up with this solution. Would be nice if there was an easier way to do this.

There is no way to change the ownership of the workspace.
The simple solution is to have user1 promote the code user2 needs into a stream and have user2 create a workspace off this stream.

You can depict a workspace as a user personal sandbox, backing a specific parent stream. Therefore, if this user1 has done significant changes on the files into his workspace, he should promote them so every other user with a workspace hanging from that stream would be updated with the changes.
So, if you only want user2 to receive all changes made by user1 on his workspace stream1_user1 (in my case, DemoDepot_juan), maybe the easiest solution would be to create a new stream (child of stream1), move user1's workspace under that stream, promote all changes and then create user2's workspace under the same stream, so it would be updated with all the changes by user1.
At this point, you could reparent user2's workspace to the inital stream, remove user1's workspace and then remove the new stream. This way, the new workspace would be identical to the old one, but the main stream will remain unmodified.

Old question, but just to say it, if this is still the state of the art, this limitation makes it impossible for an admin to set up workspaces for a new users, which they then own. Ugh.

Related

Undo zfs create

I have a problem. I created a pool consisting of single volume of 1 file 2.5Tb just to fight with file duplicates. I copied a folder with photos. Some of the photos were not backed up. Just now I see my pool folder is empty. When I checked with 'sudo zfs list' it said 'No datasets available'.
I thought it was detached and to attach I started again all these commands.
sudo zpool create singlepool -f /home/john/zfsvolumes/zfs_single_volume.dat -m /home/share/zfssinglepool
sudo zfs set dedup=on singlepool
sudo zpool get dedupratio singlepool
sudo zfs set compression=lz4 singlepool
sudo chown -R writer:writer /home/share/zfssinglepool
I see now empty pool!
May I get my folders back which I copied to the pool before I started create pool again?
Unfortunately, use of zpool create -f will recreate the pool from scratch even if ZFS recognizes that a pool has already been created using that storage:
-f Forces use of vdevs, even if they appear in use or specify a
conflicting replication level. Not all devices can be over-
ridden in this manner.
This is similar to reformatting a partition with other file systems, which will leave whatever data is there written in place, but still erase the references the file system needs to find the data. You may be able to pay an expert to reconstruct your data, but otherwise I'm afraid the data will be very hard to get back from your pool. As in any data recovery mission, I'd advise making a copy of the data ASAP on some external media that you can use to do the recovery from, in case further attempts at recovery accidentally corrupt the data even worse.

Remotely running commands via ssh

I need to automate the copy of a zip file to a remote Linux machine and then the unzipping of that file to a user's home directory.
Let's assume we have user1 and user2, user1 is a real person but has no home directory and user2 is an application user that has a home directory but cannot directly get shell access to a host. The mechanism to gain a shell for user2 is to ssh to the box as user1 and then su to user2. (please do not pass comment on this setup as I work for a large corporation and I am unable to change this aspect, it is decided by IT security and not up for discussion).
I would like to use
scp ziptocopy.zip user1#hostname:/var/tmp/
but as I don't have anywhere on the remote host to store a key file for user1 I cannot us public/private key pairs to perform this, can anyone suggest a way to do this?
The next piece is even more tricky as I want to ssh as user1 and then su to user2 and run
unzip /var/tmp/ziptocopy.zip
Again any suggestion on how I can do this? I have done a search and found an example that uses expect, this has potential for the scp but I cannot get this to work, but how would I get expect to cope with 2 password prompts?
Thanks
I'd look into using Python and the pexpect/pxssh modules. These days pexpect is a nice alternative for automation tasks that used to be dealt with using Expect.
See this answer for some example code where an SSH session is scripted:
How to make a ssh connection with python?

Backup server permissions

Currently I'm developing a control website for my home server. The server has LDAP setup for Mac's to login. The home directories are also on the server. I want to create a backup tool for my family, so they can backup while I'm off. I don't want to do this scheduled (at least not allways, since they must be able to start a backup right away).
I got stuck when I was trying to find a way to run the rsync commands as a privileged user.
I've got some ideas on this but I would like to hear the cons and pros of the options.
Create simple deamon that runs as root and backup's folder -arg1 to -arg2 minding the old backup in -arg3.
Run rsync as the logged in user by remembering the users pass at login at the control panel. (Problem: running ps will reveal password).
Create special rsync user (Problem: rsync user can read everything).
The project is located at https://github.com/hermanbanken/ldap-control and this issue is also on GitHub at https://github.com/hermanbanken/ldap-control/issues/1.
sudo is on OSX later versions.
sudo rsync .....

Run script as another user without sudo/su privileges

I'm trying to write a script so that it can be called by one user and is executed as another user. I thought that setuid might be able to do this so I enabled setuid using chmod u+s with the owner of the script being user1. I call the script (which only contains whoami right now) as user2 and it still shows user2 instead of user1. How can I make this be user1.
-- My end result is I want one user to be able to call this script and have it ssh into another server and execute a command as another user.
You can copy that user's key (id_rsa) and pass it to ssh when connecting to the server:
ssh -i user1_id_rsa user1#server
However, this is rather a bad solution, security-wise. Adding the user's key to the authorized keys on the server, as I said in the comment, is the proper way to do it, and you should really look into that.
Sounds like you need a third user in your security model, who can run the program, but is otherwise unprivileged. This third user is an assumable identity for a number of users so they can run the process on the remote server.

In Subversion can I be a user other than my login name?

I'd like to know how to get Subversion to change the name that my changes appear under.
I'm just starting to use Subversion. I'm currently using it to version control code on an XP laptop where I'm always logged in under my wife's name. I'd like the subversion DB to show the changes under my name.
Later on I'll replicate the DB so it is accessible to the whole house. My wife uses the office computer where she is always logged in under my name. I'll probably set it up so that it automatically checks in modified documents... preferably under her name.
Eventually I'll probably be using it from a linux machine under another username.
Is there some way to modify the user environment to change the user name that Subversion calls you? I'd expect something like setting SVN_USERNAME='Mark' which would override however it usually gets the name.
Update: It looks like the --username flag that Michael referred to does work to change the name reported by "svn stat", even for local file: repositories. In addition, it is sticky so you don't need to specify it for the next command. I even rebooted and it still used the "--username" value from my previous boot.
Most Subversion commands take the --username option to specify the username you want to use to the repository. Subversion remembers the last repository username and password used in each working copy, which means, among other things, that if you use svn checkout --username myuser you never need to specify the username again.
As Kamil Kisiel says, when Subversion is accessing the repository directly off the file system (that is, the repository URL is of form file:///path/to/repo or file://file-server/path/to/repo), it uses your file system permissions to access the repository. And when you connect via SSH tunneling (svn+ssh://server/path/to/repo), SVN uses your FS permissions on the server, as determined by your SSH login. In those cases, svn checkout --username may not work for your repository.
For svn over ssh try:
svn list svn+ssh://[user_name]#server_name/path_to_repo
svn will prompt you for the user_name's password.
You can setup a default username via ~/.subversion/servers:
[groups]
yourgroupname = svn.example.com
[yourgroupname]
username = yourusername
Please be aware that older versions of svn do not support it (e.g. 1.3.1 [sic!]).
"svn co --username=yourUserName --password=yourpassword http://path-to-your-svn"
Worked for me when on another user account. You will be prompted to enter username/password again though. You need to login like the above once and you are all set for the subsequent times(Unless you restart your machine).
If you need to specify a username other than your logged in user for use with svn+ssh just add an entry to your .ssh/config file:
Host example.com
User jdoe
Subversion usually asks me for my "Subversion username" if it fails using my logged in username. So, when I am lazy (usually) I'll just let it ask me for my password and I'll hit enter, and wait for the username prompt and use my Subversion username.
Otherwise, Michael's solution is a good way to specify the username right off.
Most of the answers seem to be for svn+ssh, or don't seem to work for us.
For http access, the easiest way to log out an SVN user from the command line is:
rm ~/.subversion/auth/svn.simple/*
Hat tip: http://www.yolinux.com/TUTORIALS/Subversion.html
Using Subversion with either the Apache module or svnserve. I've been able to perform operations as multiple users using --username.
Each time you invoke a Subversion command as a 'new' user, your $HOME/.subversion/auth/<authentication-method>/ directory will have a new entry cached for that user (assuming you are able to authenticate with the correct password or authentication method for the server you are contacting as that particular user).
I believe if you use the file:// method to access your subversion repository, your changes are always performed under the user which accesses the repository. You need to use a method that supports authentication such as http:// or svn://.
See http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.serverconfig.choosing
If you are using svn+ssh to connect to the repository then the only thing that authenticates you and authorizes you is your ssh credentials. EVERYTHING else is ignored. Your username will be logged in subversion exactly as it is established in your ssh connection. An excellent explanation of this is at jimmyg.org/blog/2007/subversion-over-svnssh-on-debian.html
Go to ~/.subversion/auth/svn.simple/*, and you will see a list of files that contains the information about your svn user account. Just delete all others that you don't need.
After that, when you do anything that regards to SVN operation, such as commit, rm, etc,. You will be prompt again to enter username or passwords.
TortoiseSVN always prompts for username. (unless you tell it not to)
I believe you can set the SVN_USER environment variable to change your SVN username.