Back to index

wims  3.65+svn20090927
homedir.c
Go to the documentation of this file.
00001 /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017        /* Routines to update home directory. */
00018 
00019        /* The following directories will be relocatable. */
00020        /* Clusterable directories (log, backup) should be avoided. */
00021 char *putlist[]={
00022     "public_html/modules","public_html/modules/devel",
00023       "public_html/modules/local",
00024       "public_html/bases","public_html/bases/doc",
00025       "other"
00026 };
00027 #define putcnt (sizeof(putlist)/sizeof(putlist[0]))
00028 
00029 void homedir(void)
00030 {
00031     char buf[MAX_LINELEN+1], fname[4096];
00032     char *p1;
00033     struct stat st;
00034     int i,t;
00035     for(i=0;i<putcnt;i++) {
00036        t=stat(putlist[i],&st); if(t || !S_ISDIR(st.st_mode)) continue;
00037        snprintf(fname,sizeof(fname),"%s/.wimshome",putlist[i]);
00038        accessfile(buf,"r","%s",fname);
00039        p1=find_word_start(buf); *find_word_end(p1)=0;
00040        if(strcmp(p1,cwd)==0) continue;
00041        accessfile(cwd,"w","%s",fname);
00042        chmod(fname,S_IRUSR|S_IWUSR);
00043     }
00044 }
00045