Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Setup: On LAN, I have 2 LinuxMint 18 computers that share a git repository stored on a 3rd linux computer (shared folder).
I mount the shared folder in fstab with username/password(different for computer 1 & 2), rw, file_mode=0777, dir_mode=0777
Using Caja I can open folder, create new folders,files that other person then can access and edit/delete. This is the behavior I want.
***Problem:
Using git however, I must use sudo to push to the remote repository (on 3rd shared) otherwise permission is denied. Further, when I pull from repository, some of the files from 2nd computer are locked (I don't have permission to edit). I've tried opening parent git repository folder as superuser and changing permissions to read/write for group/others and then apply permission to enclosed files. However, this does not work...1 I have to manually do it for each file and 2 git creates new files again on next push/pull that are locked again.
***Want: I want to be able to push without sudo and want files to be editable by either person on computer 1 and 2. What do I need to do to achieve this?
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To /media/NAS/WolfeServerShared/GitRepositories/Test2
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to '/media/NAS/WolfeServerShared/GitRepositories/Test2'
****
after pull, locked files are marked as root and readonly for users....likely because having to push with sudo (I'm assuming the problems are related).
But again, in caja, I (as normal user:tony) have full permissions to create/edit/delete in folder and other files other user creates.
so you push as root. That will definitely modify files (they may be owned by root). You may need to chown -R <user> <dir> or similar to restore ownership. Do not sudo git push, that is definitely not a solution but will cause additional problems (as you can see already)
Agreed, but how to I set it up so that I can access it by multiple users?
From machine 1 in GitRepositories directory (owner 1001 -user #1001 create/delete,Group 1001 create/delete,others: create/delete:
sudo chown -R tony Test2
chown: changing ownership of '[list of all files]' : Permission denied
....
....
...
From machine 3 (machine that has the folder):
folder set up as smbguest owner create/delete,group none: create/delete,others: create/delete
issue came down to difference between smb connection to folder and fstab. Using caja, I was using smb protocol, but git doesn't seem to understand smb, so needed to mount in fstab. took out my username in fstab and signed in as guest with uid=1000. I had to re-do the repository from scratch using the new permissions (still something messed up with the original repository file permissions), but new repo seems to be working now without needing to sudo.
In my opinion, the "correct" way to do this is by creating a special group for your repo. This is MUCH easier if you can initialize your repo from scratch again. I'll give you the steps for that, but you may need to google around a bit to convert a current repo to a shared one.
Code:
# Many of these command may need to be run as root.
# You need a group for your repo. Obviously you can call it whatever you like.
groupadd gitgroup
# Create the folder for your repo, and make it a member of your git group.
# Doing the setgid step at the beginning saves you some trouble later.
# The setgid step makes sure that whoever writes to the folder, all the
# other uses (in the git group) can still modify the contents of the folder.
mkdir gitrepo.git
chgrp gitgroup gitrepo.git
chmod g+s gitrepo.git
# Initialize the repo. The "shared" option is important.
git init --shared --bare ./gitrepo.git
# Now any user in the gitgroup group should be able to write to the new repo.
usermod -aG gitgroup USERNAME_OF_PERSON_WHO_NEEDS_ACCESS
# Obviously run the last command for each person who needs access.
EDIT: Note that the various sources that recommend a setup like this are generally using an ssh connection. It should work with other methods as well, but it may not be as thoroughly tested.
Last edited by springshades; 09-14-2016 at 06:18 PM.
Note that the various sources that recommend a setup like this are generally using an ssh connection. It should work with other methods as well, but it may not be as thoroughly tested.
Samba uses different filesystem and permission system, also there can be user/group mappings, so it is not really trivial. I would suggest to put that repo onto an ext4 or similar filesystem over nfs, although it may have performance problems too.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.