Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Igor Galić
- Original Message - > Hi Igor, > > I think you are wrong. > > I wrote this simple program that does what I suggested: > #include > #include > #include > > int main(int argc, char** argv){ > > uid_t low_uid = 1000; > uid_t high_uid = getuid(); > > seteuid(low_uid); // drop privilege >

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread silviu andrica
Hi Igor, I think you are wrong. I wrote this simple program that does what I suggested: #include #include #include int main(int argc, char** argv){ uid_t low_uid = 1000; uid_t high_uid = getuid(); seteuid(low_uid); // drop privilege const char* fileName="test.txt"; FILE* file = fopen(fileNa

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Igor Galić
- Original Message - > > > > What would it do when the file already exists and is owned by root? > > :) > > > > > > It is hard to distinguish between "file owned by root, but we > > should > > append to it" and "file owned by root and the admin made a mistake > > in > > the conf file".

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Eric Covener
> AFAIK, this solves the issue I raised. If I miss any > point, please let me know. Your procedure leaves the logfile deleteable by the unprivileged apache user since they were able to write to the directory to create it. - The o

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Igor Galić
- Original Message - > Hi Tom, > > > thanks for the answer. It makes perfect sense. > > > The solution I thought about is a bit more complex. I did not go > through the Apache code, so below is just a sketch. > > > seteuid(${APACHE_RUN_USER}); //drop privileges > open(${ErrorLog}); //open

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Silviu Andrica
> > What would it do when the file already exists and is owned by root? :) > > > It is hard to distinguish between "file owned by root, but we should > append to it" and "file owned by root and the admin made a mistake in > the conf file". The former is the usual case when starting a server > wi

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Tom Evans
On Thu, Nov 24, 2011 at 5:03 PM, Silviu Andrica wrote: > Hi Tom, > thanks for the answer. It makes perfect sense. > The solution I thought about is a bit more complex. I did not go through the > Apache code, so below is just a sketch. > seteuid(${APACHE_RUN_USER}); //drop privileges > open(${Error

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Silviu Andrica
Hi Tom, thanks for the answer. It makes perfect sense. The solution I thought about is a bit more complex. I did not go through the Apache code, so below is just a sketch. seteuid(${APACHE_RUN_USER}); //drop privileges open(${ErrorLog}); //open file seteuid(0); // get back root privileges chown

Re: [users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread Tom Evans
On Thu, Nov 24, 2011 at 3:53 PM, silviu andrica wrote: > Hi, > > I noticed that in Apache/2.2.20 (Ubuntu), the ErrorLog is opened as root, > although the User is set to ${APACHE_RUN_USER}. > My concern is that if I make a mistake in ErrorLog, then I can damage any > file on my system because of a

[users@httpd] Opening ErrorLog as root and overwriting any file on the system

2011-11-24 Thread silviu andrica
Hi, I noticed that in Apache/2.2.20 (Ubuntu), the ErrorLog is opened as root, although the User is set to ${APACHE_RUN_USER}. My concern is that if I make a mistake in ErrorLog, then I can damage any file on my system because of a stupid copy-paste error. I was wondering what is the reason Apache