From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,148475823a01fd49 X-Google-Attributes: gidf8c9b,public X-Google-Thread: 111c93,148475823a01fd49 X-Google-Attributes: gid111c93,public X-Google-Thread: 10b612,148475823a01fd49 X-Google-Attributes: gid10b612,public X-Google-ArrivalTime: 2000-09-21 17:40:10 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!xfer13.netnews.com!netnews.com!newsfeed.skycache.com!Cidera!typhoon.sonic.net!news.idiom.com!idiom.com!jadestar From: "James T. Dennis" Newsgroups: comp.os.linux.alpha,comp.unix.questions,comp.unix.ultrix Subject: Re: Help: Apache Web server Date: 22 Sep 2000 00:11:52 GMT Organization: Idiom Communications Message-ID: <8qe848$2sgb$1@news.idiom.com> References: <39c7b02e@news.alphalink.com.au> <39C7AFF1.DECEEC28@nospam.guacamole.com> <39CA654B.9B820291@nospam.guacamole.com> NNTP-Posting-Host: idiom.com X-Trace: news.idiom.com 969581512 94731 216.240.32.1 (22 Sep 2000 00:11:52 GMT) X-Complaints-To: abuse@idiom.com NNTP-Posting-Date: 22 Sep 2000 00:11:52 GMT User-Agent: tin/pre-1.4-980818 ("Laura") (UNIX) (FreeBSD/3.5-RELEASE (i386)) Xref: supernews.google.com comp.os.linux.alpha:603 comp.unix.questions:1511 comp.unix.ultrix:27 In comp.os.linux.alpha Marble Head wrote: >> cd /home >> chmod 711 ~user >> chmod 755 ~user/public_html >> chmod 644 ~user/public_html/ >> chmod 755 ~user/public_html/ > Have you tried this? > It doesn't seem to make sense to me. Why the ~ in front of user? > Is that a special folder somebody created, or is it part of > their login name, or a type-o, or something I don't understand? It's something you don't understand. It's also pretty basic UNIX/Linux so it is generally assumed that users will understand it. From most (almost all) UNIX shells (command line interpreters/ interfaces) the ~ (tilde or "twiddle") is an abbreviation for "the home directory of." So ~/foo is the "foo" file or directory under (the current user's) home directory. ~foo/bar is "the bar file or directory under the home directory of the user named "foo." (Note that "foo" and "bar" are traditional "meta variables" --- the are used in examples just the way that you math teacher might have used "a" and "b"). In common URL usage the ~ has a similar meaning. The NCSA Apache and many other web servers are configured to take a URL of the form ~foo (as in http://somewhere.not/~foo/bar.html) and expand it to "the public_html directory under the home directory of user foo." This is a slightly different but rather "intuitive" interpretation to people who are used to the common UNIX meaning of the ~. Considering that the web and the Inernet were primarily developed by UNIX programmers and users this makes alot of sense. It's possible that your web server may be configured to treat ~ characters in URLs differently. For example I usually configure my systems to use ~*/.web/ instead of ~*/public_html/ as "the user's web files." That's because I prefer the shorter name and I don't need to see my "web" directory tree every time I do an ls in my home directory. It's also possible that your web server might be configured to ignore the ~ completely. Also note that it is technically not strictly conformant with the standards to put a ~ in a URL --- it's supposed to be encoded (%7E??) though it's quite rare in practice. > Also, on my system, in order for httpd to reach the > /home/joeuser/public_html/* files, all of those paths needed > to be read and execute permissions, in other words, 755. Should read: "those paths need to be 'world accessible'..." Technically you just have to make sure that your public_html directory is accessible to the web server. The web server should be running under its own special user ID (often named "web"). You might be able to accomplish this with just group permissions (mode 750 on public_html and possibly on your home directory as well). However, it's usually pretty unlikely that you'd want to serve web pages from a "public_html" directory that you would want to keep confidential from other local users. It's possible to do that sort of think using CGI programs and the Apache suExec module if you really need to. > Here's another idea: > In the apache configuration files somewhere, there must be a > setting that tells it "When you get a request for > http://www.domain.com/~user, look in the /home/user/public_html > folder," because not every system puts the users under /home. It is correct that there is such a setting. However, that is completely indepedent of the fact that some users might have home directories that are not under /home. The normal UNIX mechanism for looking up a user's home directory (and for matching numeric UIDs to user names, and for looking up other "locally public" information about any UNIX account is to use the getpwent() library functions. This could provide a directory name under /home for one user and a directory under /usr/share for another, etc. The getpwent() function traditionally looked through the /etc/passwd file. On modern versions of UNIX it might look up information via a set of NIS maps, it might access a set of dbm "hash/index" files, or it might use other mechanisms. On a GNU/Linux or other GNU system (one using the GNU glibc 2.x libraries) it might involve the library loading various .so (shared object) files and querying any sort of back-end directory service (LDAP, Hesiod, etc). So, if the ~ feature of your web server is enabled it is not likely to be doing a simple string replacement of ~ with something like /home/.../public_html/ --- it's almost certainly doing a proper getpwent() and then appending the "public_html" or other directory name to the end of that. > So that setting must be changeable, for example, to > /home/personalpages/user. If the users want the public_html > folder in their regular /home/user folder, make a softlink. The web server might be configured not to follow symbolic links. > Allow the full 755 permissions on /home/personalpages, because > if it's public anyway (accessible through http://www.domain.com/~user) > then who will be upset that somebody read it? And you still can > preserve normal permissions on your /home/user folder. Actually it is possible (if one was using .htaccess) that one might want to keep "confidential" data under a ~/public_html/ directory tree. One news poster recently posed a question (I don't remember where) that described a set of patches to their web server that caused the web server to adopt the same effective user ID as the owner of a file/directory that was listed in the URL. This allegedly provided the desired level of additional security (although it seems quite risky since it might have had its own bugs that make the whole server MUCH more dangerous; I'd recommend a mechanism where the primary web server could "hand off" any ~foo/ URL requests to a different process (file descriptors, including those bound to internet domain sockets can be passed via UNIX domain sockets) and have each user that wanted this sort of feature running a custom process (probably running with a specific supplemental group) --- that should be much safer).