Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Oct 2001 06:30:18 +1300
From:      Craig Carey <research@ijs.co.nz>
To:        freebsd-questions@freebsd.org
Subject:   Re: Stupid, stupid ... ( GLOBIGNORE=..
Message-ID:  <5.1.0.14.2.20011031062051.03648cc0@202.89.128.27>
In-Reply-To: <Pine.LNX.4.30.0110281215010.19082-100000@sg1.indexthis.net >

next in thread | previous in thread | raw e-mail | index | archive | help
At 01.10.28 12:17 -0500 Sunday, Philip Mak wrote:
 >I just did a stupid thing to lock myself out of one of my boxes that I
 >only have remote ssh access to. I thought I'd share it with you guys so
 >that no one else makes the same mistake.
 >
 >Never type "chmod o-rx .*" when logged in as root, inside root's home
 >directory (/root). That will affect .. as well, meaning that the directory
 >"/" will no longer be accessible to normal users.
 >

GNU chmod does not contain globbing code.

If the shell is bash, then a solution is to use "GLOBIGNORE=..".

-----------------------------------------------------

What happens when the command is "chmod 000 .*" :

Case 1: When GLOBIGNORE=
    then all the files in the current directory with names starting with
    "." or ".." are made read only. Also so are the directories "." and
    "..".

Case 2: When GLOBIGNORE=..
    then the .* and ..* files are also altered, and the "." and ".."
    directories are not altered.

-----------------------------------------------------

Setting "GLOBIGNORE=.." is able to stop commands affecting the directory
  above when they get the glob pattern: ".*".
That could be put into a bash "profile" file or ".bashrc" file.

  Bash: GLOBIGNORE
     A colon-separated list of patterns defining the set of filenames to
     be ignored by pathname expansion. If a filename matched by a
     pathname expansion pattern also matches one of the patterns in
     GLOBIGNORE, it is removed from the list of matches.












 >Now I can't ssh into my box (any attempt to connect will say "Cannot find
 >root directory" and kick me out) to fix this, so I have to wait for the
 >guy who has physical access to the box to fix it.
 >
 >
 >To Unsubscribe: send mail to majordomo@FreeBSD.org
 >with "unsubscribe freebsd-questions" in the body of the message


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.1.0.14.2.20011031062051.03648cc0>