Solved /home/me permission issues

  • Thread starter Thread starter Deleted member 43773
  • Start date Start date
D

Deleted member 43773

Guest
Hi all readers,

I'am trying to set up a little copy script for backup selected files from my /home/me (FreeBSD 12.1 on a ZFS)

When I am trying to use cp with full path of the file(s) to be back upped in a script, I receive either "file not found" or "permission denied" (on reading (!?) - I am the owner of my /home/me, directories have x bits set, also as the permissions are set (drwxr-rr-x) - I also receive "permission denied" when i run the script as root...) - and the file(s) exists.

So I thought a shellscript executed might not have the same permissions as the user who owns and started it - but it runs under my name, so I suggest for at least really simple scripts that should not the problem. Or the data being processed by a script going "other ways" as when I use the shell command via terminal...(?)

If I try to use cpio, what I'd rather like to do, because of its capability of generating a clone of the path (subdirectories) of a file, I receive "Cannot extract through symlink".
Besides I don't see, why cpio -pdmu .... "extracts" anything in this case I understood, there seems to be some kind of link (what also might explain the permission issue, when in this case the access is done not directly, but via a link from somewhere else (?) where I don't have permissions - but I don't see it.
Yet I didn't find a link pointing at my /home/, and besides /usr/home/ I also don't know where to look for such.
There are two home-fs: /home/ and /usr/home/, where /usr/home/ seems to be empty and exists for "traditional"/compatibility(?)-purposes; at least I didn't found any link yet, that redirects from on home to the other.

What I think I understood so far:
- It's quite a difference how I pass the options to a command/filter within the script:
find .... | cpio ... produces a "Cannot extract through symlink"
but
find ... > textfile
read line < textfile
$line | cpio... produces a "permission denied", even it seems to be the same thing
(you see, I also still need to do some studying on scripting, too ;-)
But neither way works. Also it has nothing to do with (wrong) quoting, which may only produce the same results or an additional "file not found".
So I understand point is not my scripting, but my insufficient knowledge of the system.

- There is more than one way to access to a file, even if the path seems the same - depends on who (me/script) handles it.
What really bothers me is the "symlink" message.
Is it possible that my /home/. directory is not really the fs it seems to be, but a link, and where is it placed, where is the link, from where, how can I see it (no obvious links are shown to me so far) - how can i figure that out (/usr/home is empty) ?

#cd brings me in my /home/ #~ gives me a "permission denied"
I know that ~ this is no "change-directory" command, but simply a shortform of /home/me, rather $HOME - but is it normal to receive a "permission denied" instead of a "this is no command/I don't know what to do"? There seems to be a difference between /home/me and $HOME.

%zfs list shows me a mountpoint on /usr/home, but none on /home/ - and yet I didn't found any link from one to the other.
So it seems to me /usr/home is needless, and /home is "just a subdirectory" of / (root)
How can I figure out the exact location/mountpoint/path of my /home/?

I think to do %zfs create pool/home %zfs set mountpoint=/home pool/home BUT
- I'am not sure if this solves my problem
- And what happens then to my current /home/directories? Would that not cause to produce problems, because I'd have two /home fs - one via zfs and the other one from... "the system"(?), something like twice the same mountpoint, from two aspects, to two different locations?

On the other hand I think it may be possible to move my home-directories from /home to /usr/home - but all links pointing at /home would be broken then (if there are any), and I don't know, how to figure out, what points all at /home...and I don't know If this solves my problem, because I don't understand the cause of it.
...or shall I make a symlink from /usr/home to /home - but I also don't see how this would solve my permission problem....

Please, no side-topic discussions like "Why do you want to do backups like this, and don't...." - The purpose of my script is subsidiary;
I simply want to understand the ways of how a /home/me is part within the fs, and how this can lead to different access ways/permissions (if there are any), even if I own the directory and have the permissions.

Just experimenting wildely is not an option - my system is not a fresh installed "virgin" anymore... - and I don't want the things just get running, not really knowing why, I want to understand.

thanks in advance

Profighost
 
I don't use cpio. With that in mind ...

#cd brings me in my /home/ #~ gives me a "permission denied"
I know that ~ this is no "change-directory" command, but simply a shortform of /home/me, rather $HOME - but is it normal to receive a "permission denied" instead of a "this is no command/I don't know what to do"?
Try "cd ~". Typing '~' alone gives you the error described. '~' isn't a command but a parameter to a command.

Typing "cd" alone takes you back to shell's previous directory. For example, you were in directory A. You type "cd B" and then type "cd". You will be back in A. Type "cd" again you will be in directory B.

While you're at it, also try "cd $HOME".

There seems to be a difference between /home/me and $HOME.
You can verify that by typing "echo $HOME".

On the other hand I think it may be possible to move my home-directories from /home to /usr/home -
/home is already a symlink to /usr/home. You can see this by type "ls -la /".

Assuming "me" is your username and this user was created using default options - your $HOME directory will be /usr/home/me. You can also use /home/me since /home points to /usr/home.

Assuming ZFS is working ... you should not need to summon the zfs command to backup a few files.
 
Thank you to address my prob and thanks for your answer.

ls -la / shows me
drwx--x--x ... root wheel ... home
seems to be a normal directory to me. Wouldn't it be lrwx.... if it were a link, such as sys -> usr/src/sys?
And if /home would be linked/redirected to /usr/home and I cd into /usr/home/ wouldn't I see the user's home directories and their contents in it, instead just
drwxr-xr-x .
drwxr-xr-x ..
only (Looks like an empty directory to me) ?
When I cd into /home/.. I see my user's home directories and their contents.

I would understand vice versa, if /usr/home is not a directory only, but also be linked to /home by a link I cannot see/don't know where it is, but this way around I don't understand why and how a non empty directory should be linked to an empty /usr/home.


I know - at least I thought I'd knew - that ~ means $HOME means /home/me, and if I echo $HOME or echo ~ I also receive /home/me. I already checked that out. But when using within a shell script there may are situations where they seem to be handled differently - not being the absoluty exactly the same - and I don't know/understand when, why and how this effects permissions or if files are found - that's bothering me.

Unfortunately hier(7) gives no info about neither /home nor /usr/home.
 
From the manpage of ln(1):
"Directories may not be hardlinked, and hard links may not span file systems.
 
Maybe you should show a piece of code that produce these inexpected results (the smaller possible). Also explain what you want to achieve.

I don't really understand what is the problem. You tried many things but the base one, I mean cp doesn't work as you want. You'd better to stop here and focus to understand what happen.
 
That's exactly, what I am trying to do.... since I don't know if the problem is caused by the system (FreeBSD), the script (shell) or zfs related it's also hard to me, to ask a specific question.
I am going to try to transfer my /home to /usr/home this afternoon, run some further tests and post here my results (also the code, that bothers me - it's simple, really).
Read you later, and thanks again.
 
I am pretty sure it has nothing to do with scripting, but it seems I have some kind of a little mess within my filesystem, since it seems the permissions/paths/links are not completely 100% right on all ... - "levels"(?)
I read SirDices post (3rd last from bottom) in Forum "[...]due permission denied"
It seems to me it's something worth a try to also look in this direction.

It's not just "chmod related", only - at least I think it's worth a try to look anywhere else (I do know the man page of chmod, thank you, /home and /home/usernames are drwxr-xr-x, wouldn't ask a question within a forum if it would be just that easy.)

At the moment my homes are within /home/usernames
where home is a directory under zpool/ROOT/default mountpoint / (root)
also $HOME contains this path and it's system's default where to place new user homes.

Additionally there is an /usr/home which exists as zpool/usr/home mountpoint /usr/home, which is empty. (under non-zfs FreeBSD /usr/home also exists, and it's also empty - at least on my machines after default installation.)
However:
The mountpoint /usr/home was set by default by zfs, but no /home mountpoint was set by zfs.
one, /home, is FreeBSD default, and the other /usr/home is zfs default, since /usr/home has its own mountpoint, but /home doesn't.
And since this is the very first example in the man page of zfs - creating a home-pool and mounting it as /home, what I not did and then let FreeBSD produce the user's homes into /home, I think it's woth a try to look in this direction, understanding, if my problems are caused somewhere in this area.

For me it still seems, there seems to be somekind of "unfortunate existing" of two parallel /home-paths. Not absolutely 100% the identical same, but in some kind of "upper-level small key-issues" which may produce permission conflicts...? (You see, I'm circling around in the woods, not seeing the trees anymore.. :-)

So one of my ideas is to create a zpool/home with a mountpoint to /home.
The other one is just move user's homes to /usr/home.
Either way I don't know if this would solve my problem - but I think it would be worth try as long as I do not kill my system/lose data.

With the second idea - move to /usr/home I would have to tell the system, that default home is not /home anymore but /usr/home .... and I don't know what all depends on this besides /etc/master.passwd, /etc/... etc.

The first idea - I didn't try it yet, because I want to get some opinions from you guys first, because I see to run into new troubles then, like having the same path at two locations.

Of course when I create zpool/home and then mount it as /home there are problems with my users, because this /home still is empty yet, of course. But I could move the contents from my current /home to the new zpool/home.
(copy old-/home to /tempanywhere/, mount zpool/home, copy /tempanywhere/ to new-/home)

I'm pretty sure the data then still exists in the 'old' /home and I'm afraid that may produce conflicts, because there will be the new one zpool/home mounted as /home, and additionally there still exists the subdirectory home within the mountpoint of / (root) - two places, one path; this ain't no good... And I don't know, if there are more than one way to address /home then and the system may get trouble accessing to one and the other...

I don't know, if this solves my problem at all, instead of
"just setting the things right for my existing system" - but for that, indeed, I need to know, what's wrong.

Are there some kind of a test, which I could run, cause anybody to say:"Ah, yeah, that ... is not set right."? Finding out, what links (hard/sym) are pointing at my /home, or how/what is /home actually from the system's point of view?

What I want to understand is the difference between the zfs and the mountpoints/links of the OS - how can I address/look at a ZFS's "directory" resp. distinguish zpool/home /home from zpool/ROOT/default / home ?


thanks a lot, guys!
 
(removed the quote because the forum is acting up on me and I can't find out what I might be doing wrong)

Look into the zfs(8) manualpage, it's the tool required for all this. No offense but your problem seems to be centered about a lack of basic understanding regarding FreeBSD (mountpoints in specific) as well as ZFS. Could be wrong, have to admit that I didn't read your post in-depth, but reading it only brings up more questions about what your exact problem is. Be more specific.

To answer the above... hier(7) might be a good read, as well as the FreeBSD handbook (in specific the installation chapter). There is a hierarchy but you could dump everything onto one slice if you wanted to (so you'd have a / and that's it). Mountpoints are merely locations where you gain access to a different filesystem.

As to ZFS... mount point definitions are part of the dataset properties, which can be displayed using zfs get mountpoint <dataset>. For example:

Code:
magi:/home/peter $ zfs get mountpoint zroot/src
NAME       PROPERTY    VALUE       SOURCE
zroot/src  mountpoint  /usr/src    local
Don't mind the different dataset names, I always set up ZFS manually because I dislike the (IMO) inefficiency of the default installer.

Anyway, it seems you're getting confused about the dataset name, its mountpoint property and of course the mountpoint. Datasets are shown using zfs list. By default that gets you both properties: the name & mountpoint. As shown above, for more reference:

Code:
magi:/home/peter $ zfs list -r zroot/var
NAME               USED  AVAIL  REFER  MOUNTPOINT
zroot/var          158M   102G  25.9M  /var
zroot/var/db       131M   102G   119M  /var/db
zroot/var/db/pkg  12.3M   102G  12.3M  /var/db/pkg
zroot/var/log      986K   102G   986K  /var/log
zroot/var/mail     102K   102G   102K  /var/mail
zroot/var/run     53.5K   102G  53.5K  /var/run
zroot/var/tmp       23K   102G    23K  /var/tmp
 
Quotes should be used very carefully. They are some kind of a plague within forums - I hate it, if people always quote the complete (direct) former post - especially when they are as epic as my ones - just to write "I neither don't know."
Someone who tries to get useful information out of a thread, and you have to read the same stuff multiple times plus filled with "wise signatures", one may dream of shotguns :-D

As for hier(7): I already read it before I started this thread, and now I checked it the 4th time:
There is nothing about /home nor /usr/home in it.

No offense taken, I do see it the same way, that's what I ment with "I have some kind of a little mess within my filesystem" - but it's not that simple as just the "chmod permissions" are overseen.

Maybe this could be part of a clue:
Yesterday I created zpool/home, mounted and then umounted it again - have no data written to it.
Since I think I understood that zfs mount adds mountpoints (not in fstab) I checked after unmouting the pool again that %mount does not show any mountpoint to zpool/home.
After restart my user logged in into somekind of an empty directory. After removing the empty pool/home and restarting again, I could login as usual.
So even if I don't see no mountpoint to zpool/home something points to it/prefer to use it.

However, thanks a lot - I keep working on it.
Every new hint/tip new is something I only will learn from.
And when I found the solution, I will post it here.

Thanks a lot.
 
SOLVED

The point was: I was trying to backup my /home/me/* to another directory on another machine, and the target nfs-directory was accessed through a symlink.
That is not working. I can cp but not cpio through a symlink.
So under some circumstances to use a link is not the same as using the direct path resp. the symlink cannot be used/is not allowed, and it seems to me it depends on the used command/program, too.
I presume under some circumstances there are some limitations and restrictive measures by the filesystem/system itself to prevent security issues - but I really don't know actually yet.
Is it zfs, nfsv4, cpio, ssh or FreeBSD related?
(That's why I cannot put it as a specific question - where to look for?)


However - this is the way I solved it:
My script cpios the files (and their paths [previous find > file and filtering {sed ... > file} done])
to a direct adressed temp-directory first, which then is cp copied through the symlink to its destination.

Thanks to all readers for trying to understand and help.
 
The usual way to avoid using cpio to copy through a symlink:
Code:
SOURCE=/home/me
TARGET=whatever
TARGET=$(cd $TARGET && /bin/pwd) || exit 1
cd $SOURCE || exit 2
find . -depth -print | cpio -pdmu $TARGET
 
Back
Top