LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 09-13-2016, 06:04 AM   #1
aw_wolfe12
LQ Newbie
 
Registered: Sep 2016
Posts: 7

Rep: Reputation: Disabled
permission issues with git on shared LAN


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?

Thanks,

Tony
 
Old 09-13-2016, 07:23 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,630

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
how did you really mount those drives? what was the exact error message you got? which files were locked?
 
Old 09-13-2016, 07:46 AM   #3
aw_wolfe12
LQ Newbie
 
Registered: Sep 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
fstab entry

//wolfeserver1/shared /media/NAS/WolfeServerShared cifs username=tony,password=[password],rw,file_mode=0777,dir_mode=0777 0 0

****
error message from a git push without sudo:

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.
 
Old 09-13-2016, 07:51 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,630

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
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)
 
Old 09-13-2016, 09:05 AM   #5
aw_wolfe12
LQ Newbie
 
Registered: Sep 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
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

Again, this works in caja, just not with git.

Tony
 
Old 09-13-2016, 04:40 PM   #6
aw_wolfe12
LQ Newbie
 
Registered: Sep 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.
 
Old 09-14-2016, 06:10 PM   #7
springshades
Member
 
Registered: Nov 2004
Location: Near Lansing, MI , USA
Distribution: Mainly just Mandriva these days.
Posts: 317

Rep: Reputation: 30
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.
 
Old 09-15-2016, 01:55 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,630

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
Quote:
Originally Posted by springshades View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 02:09 PM
No Permission to see the contents in the mounted shared folder raju.muppana Linux - Networking 4 06-24-2010 01:33 PM
permission on shared hd android6011 Linux - General 2 11-05-2005 07:10 PM
In samba no permission to see shared file ALInux Linux - Software 1 04-22-2005 07:26 AM
Persistent File Permission s on Shared Directories jackiemcghee Linux - General 3 07-15-2004 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration