linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* True story: "gconfig" removed root folder...
@ 2004-01-15 14:36 Ozan Eren Bilgen
  2004-01-15 15:05 ` Roman Zippel
                   ` (5 more replies)
  0 siblings, 6 replies; 34+ messages in thread
From: Ozan Eren Bilgen @ 2004-01-15 14:36 UTC (permalink / raw)
  To: linux-kernel

Hi,

Today I downloaded 2.6.1 kernel and tried to configure it with "make
gconfig". After all changes I selected "Save As" and clicked "/root"
folder to save in. Then I clicked "OK", without giving a file name. I
expected that it opens root folder and lists contents. But this magic
configurator removed (rm -Rf) my root folder and created a file named
"root". It was a terrible experience!..

Please fix this. I didn't check that same problem (I even didn't launch
them) exist for other configurators then gconfig.

I send this mail here because I guessed that the configurator is a part
of kernel.

Note: (As you wished) Please CC me your responses.


TIA
-- 
Comp. Eng. Ozan Eren BILGEN

TUBITAK - UEKAE (Turkey)
National Research Institute of Electronics & Cryptology
Special Projects Group
Researcher



^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
@ 2004-01-15 15:05 ` Roman Zippel
  2004-01-15 15:20   ` Doug McNaught
  2004-01-15 21:23   ` Romain Lievin
  2004-01-15 15:40 ` viro
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 34+ messages in thread
From: Roman Zippel @ 2004-01-15 15:05 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: linux-kernel

Hi,

On Thu, 15 Jan 2004, Ozan Eren Bilgen wrote:

> Today I downloaded 2.6.1 kernel and tried to configure it with "make
> gconfig". After all changes I selected "Save As" and clicked "/root"
> folder to save in. Then I clicked "OK", without giving a file name. I
> expected that it opens root folder and lists contents. But this magic
> configurator removed (rm -Rf) my root folder and created a file named
> "root". It was a terrible experience!..

I only did a quick check with menuconfig. Are you sure it's really
removed? It should still be there as "/root.old".
I probably should change the behaviour of the save routine to behave
differently for directories as argument, but it doesn't remove it.
(Changing gconfig to only accept files in the save request would probably
be nice too...)

bye, Roman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:05 ` Roman Zippel
@ 2004-01-15 15:20   ` Doug McNaught
  2004-01-15 15:37     ` Erik Hensema
  2004-01-16 17:20     ` Max Valdez
  2004-01-15 21:23   ` Romain Lievin
  1 sibling, 2 replies; 34+ messages in thread
From: Doug McNaught @ 2004-01-15 15:20 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Ozan Eren Bilgen, linux-kernel

Roman Zippel <zippel@linux-m68k.org> writes:

> On Thu, 15 Jan 2004, Ozan Eren Bilgen wrote:
>
>> Today I downloaded 2.6.1 kernel and tried to configure it with "make
>> gconfig". After all changes I selected "Save As" and clicked "/root"
>> folder to save in. Then I clicked "OK", without giving a file name. I
>> expected that it opens root folder and lists contents. But this magic
>> configurator removed (rm -Rf) my root folder and created a file named
>> "root". It was a terrible experience!..
>
> I only did a quick check with menuconfig. Are you sure it's really
> removed? It should still be there as "/root.old".
> I probably should change the behaviour of the save routine to behave
> differently for directories as argument, but it doesn't remove it.
> (Changing gconfig to only accept files in the save request would probably
> be nice too...)

The real lesson here is "don't compile your kernel as root".  There's
no need to do so.

-Doug

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:20   ` Doug McNaught
@ 2004-01-15 15:37     ` Erik Hensema
  2004-01-15 16:07       ` Tim Cambrant
  2004-01-17 16:47       ` Alban Browaeys
  2004-01-16 17:20     ` Max Valdez
  1 sibling, 2 replies; 34+ messages in thread
From: Erik Hensema @ 2004-01-15 15:37 UTC (permalink / raw)
  To: linux-kernel

Doug McNaught (doug@mcnaught.org) wrote:
> Roman Zippel <zippel@linux-m68k.org> writes:
> 
>> On Thu, 15 Jan 2004, Ozan Eren Bilgen wrote:
>>
>>> Today I downloaded 2.6.1 kernel and tried to configure it with "make
>>> gconfig". After all changes I selected "Save As" and clicked "/root"
>>> folder to save in. Then I clicked "OK", without giving a file name. I
>>> expected that it opens root folder and lists contents. But this magic
>>> configurator removed (rm -Rf) my root folder and created a file named
>>> "root". It was a terrible experience!..
>>
>> I only did a quick check with menuconfig. Are you sure it's really
>> removed? It should still be there as "/root.old".
>> I probably should change the behaviour of the save routine to behave
>> differently for directories as argument, but it doesn't remove it.
>> (Changing gconfig to only accept files in the save request would probably
>> be nice too...)
> 
> The real lesson here is "don't compile your kernel as root".  There's
> no need to do so.

Yes, having your user homedirectory removed is *much* better :-)

-- 
Erik Hensema <erik@hensema.net>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
  2004-01-15 15:05 ` Roman Zippel
@ 2004-01-15 15:40 ` viro
  2004-01-15 16:01   ` Jan-Benedict Glaw
  2004-01-15 21:05 ` Romain Lievin
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 34+ messages in thread
From: viro @ 2004-01-15 15:40 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: linux-kernel

On Thu, Jan 15, 2004 at 04:36:45PM +0200, Ozan Eren Bilgen wrote:
> Hi,
> 
> Today I downloaded 2.6.1 kernel and tried to configure it with "make
> gconfig". After all changes I selected "Save As" and clicked "/root"
> folder to save in. Then I clicked "OK", without giving a file name. I
> expected that it opens root folder and lists contents. But this magic
> configurator removed (rm -Rf) my root folder and created a file named
> "root". It was a terrible experience!..
> 
> Please fix this. I didn't check that same problem (I even didn't launch
> them) exist for other configurators then gconfig.
> 
> I send this mail here because I guessed that the configurator is a part
> of kernel.

*ugh*

gconfig behaviour aside, why on the earth are you running GUI code (_any_
GUI code) as root?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:40 ` viro
@ 2004-01-15 16:01   ` Jan-Benedict Glaw
  0 siblings, 0 replies; 34+ messages in thread
From: Jan-Benedict Glaw @ 2004-01-15 16:01 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

On Thu, 2004-01-15 15:40:39 +0000, viro@parcelfarce.linux.theplanet.co.uk <viro@parcelfarce.linux.theplanet.co.uk>
wrote in message <20040115154039.GG21151@parcelfarce.linux.theplanet.co.uk>:
> On Thu, Jan 15, 2004 at 04:36:45PM +0200, Ozan Eren Bilgen wrote:

> gconfig behaviour aside, why on the earth are you running GUI code (_any_
> GUI code) as root?

I think he already learned that lesson. This time, it was the hard way...

MfG, JBG

-- 
   Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:37     ` Erik Hensema
@ 2004-01-15 16:07       ` Tim Cambrant
  2004-01-15 16:17         ` Valdis.Kletnieks
  2004-01-17 16:47       ` Alban Browaeys
  1 sibling, 1 reply; 34+ messages in thread
From: Tim Cambrant @ 2004-01-15 16:07 UTC (permalink / raw)
  To: Erik Hensema; +Cc: Linux Kernel Mailing List

On Thu, Jan 15, 2004 at 03:37:09PM +0000, Erik Hensema wrote:
> Yes, having your user homedirectory removed is *much* better :-)

How about using /usr/src and giving permissions to that directory
to your non-root user?

                Tim Cambrant

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 16:07       ` Tim Cambrant
@ 2004-01-15 16:17         ` Valdis.Kletnieks
  2004-01-15 18:31           ` Tim Cambrant
  0 siblings, 1 reply; 34+ messages in thread
From: Valdis.Kletnieks @ 2004-01-15 16:17 UTC (permalink / raw)
  To: Tim Cambrant; +Cc: Erik Hensema, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

On Thu, 15 Jan 2004 17:07:59 +0100, Tim Cambrant said:
> On Thu, Jan 15, 2004 at 03:37:09PM +0000, Erik Hensema wrote:
> > Yes, having your user homedirectory removed is *much* better :-)
> 
> How about using /usr/src and giving permissions to that directory
> to your non-root user?

So /usr/src gets removed instead.

That's not fixing the problem, it's moving it around the filesystems.


[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 16:17         ` Valdis.Kletnieks
@ 2004-01-15 18:31           ` Tim Cambrant
  2004-01-15 18:49             ` Valdis.Kletnieks
  2004-01-15 19:00             ` Richard B. Johnson
  0 siblings, 2 replies; 34+ messages in thread
From: Tim Cambrant @ 2004-01-15 18:31 UTC (permalink / raw)
  To: Valdis.Kletnieks; +Cc: Linux Kernel Mailing List

On Thu, Jan 15, 2004 at 11:17:32AM -0500, Valdis.Kletnieks@vt.edu wrote:
> That's not fixing the problem, it's moving it around the filesystems.
> 

Would it really? If we use /usr/src/linux (for example) to store
the code of one single kernel and have a user with permission to
write to /usr/src/linux and not to /usr/src, then he couldn't
remove /usr/src, but only /usr/src/linux, right?

I'm not sure if I understand you correctly, and you might mean
that the problem in make gconfig isn't fixed. That's true, but
I'm not the maintainer so I'm just trying to help you find a
solution that will work for now.


                Tim Cambrant

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 18:31           ` Tim Cambrant
@ 2004-01-15 18:49             ` Valdis.Kletnieks
  2004-01-15 19:00             ` Richard B. Johnson
  1 sibling, 0 replies; 34+ messages in thread
From: Valdis.Kletnieks @ 2004-01-15 18:49 UTC (permalink / raw)
  To: Tim Cambrant; +Cc: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

On Thu, 15 Jan 2004 19:31:25 +0100, Tim Cambrant said:

> I'm not sure if I understand you correctly, and you might mean
> that the problem in make gconfig isn't fixed. That's true, but

Right.  It's not fixed.

> I'm not the maintainer so I'm just trying to help you find a
> solution that will work for now.

Well, unfortunately, saying "Well, don't do that then" is about as much of a
workaround as we can manage till gconfig actually gets fixed.

What I'm worried about is a semi-clued user who will read the lkml archives,
see the "just do this" discussion, and think that it's actually a fix rather than
a retargeting of the ICBM ;)

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 18:31           ` Tim Cambrant
  2004-01-15 18:49             ` Valdis.Kletnieks
@ 2004-01-15 19:00             ` Richard B. Johnson
  2004-01-15 19:30               ` Valdis.Kletnieks
  2004-01-15 19:48               ` Erik Hensema
  1 sibling, 2 replies; 34+ messages in thread
From: Richard B. Johnson @ 2004-01-15 19:00 UTC (permalink / raw)
  To: Tim Cambrant; +Cc: Valdis.Kletnieks, Linux Kernel Mailing List

What is (a) "root folder"?
The two words don't go together at all. Unix/Linux has "root" and
directories, but it doesn't have any "folders". Microstuff has
"folders", but doesn't have "root". Is Gates infecting Linux?
I heard that "folder" was a swear-word just like the other "f"
word.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 19:00             ` Richard B. Johnson
@ 2004-01-15 19:30               ` Valdis.Kletnieks
  2004-01-15 19:48               ` Erik Hensema
  1 sibling, 0 replies; 34+ messages in thread
From: Valdis.Kletnieks @ 2004-01-15 19:30 UTC (permalink / raw)
  To: root; +Cc: Tim Cambrant, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

On Thu, 15 Jan 2004 14:00:10 EST, "Richard B. Johnson" said:

> directories, but it doesn't have any "folders". Microstuff has
> "folders", but doesn't have "root". Is Gates infecting Linux?

Yes.

http://www.informationweek.com/story/showArticle.jhtml?articleID=17300643
http://www.microsoft.com/windows/sfu/downloads/default.asp

:)

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 19:00             ` Richard B. Johnson
  2004-01-15 19:30               ` Valdis.Kletnieks
@ 2004-01-15 19:48               ` Erik Hensema
  1 sibling, 0 replies; 34+ messages in thread
From: Erik Hensema @ 2004-01-15 19:48 UTC (permalink / raw)
  To: linux-kernel

Richard B. Johnson (root@chaos.analogic.com) wrote:
> What is (a) "root folder"?
> The two words don't go together at all. Unix/Linux has "root" and
> directories, but it doesn't have any "folders". Microstuff has
> "folders", but doesn't have "root". Is Gates infecting Linux?
> I heard that "folder" was a swear-word just like the other "f"
> word.

The kernel doesn't impose a policy on user space, so a 'directory
vs folder' discussion is offtopic here. Let userspace decide.

-- 
Erik Hensema <erik@hensema.net>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
  2004-01-15 15:05 ` Roman Zippel
  2004-01-15 15:40 ` viro
@ 2004-01-15 21:05 ` Romain Lievin
  2004-01-15 21:44 ` [PATCH] " Romain Lievin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 34+ messages in thread
From: Romain Lievin @ 2004-01-15 21:05 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: Linux Kernel Mailing List

Hi,

On Thu, Jan 15, 2004 at 04:36:45PM +0200, Ozan Eren Bilgen wrote:
> Hi,
> 
> Today I downloaded 2.6.1 kernel and tried to configure it with "make
> gconfig". After all changes I selected "Save As" and clicked "/root"
> folder to save in. Then I clicked "OK", without giving a file name. I
> expected that it opens root folder and lists contents. But this magic
> configurator removed (rm -Rf) my root folder and created a file named
> "root". It was a terrible experience!..
> 

I attempted to reproduce your steps but it did not remove my /root directory.
Instead of that, gconf created a .config file in the root dir.

> Please fix this. I didn't check that same problem (I even didn't launch
> them) exist for other configurators then gconfig.
> 

Maybe I should avoid empty file name. It will be fixed in a further patch.

> I send this mail here because I guessed that the configurator is a part
> of kernel.
> 
> Note: (As you wished) Please CC me your responses.
> 
> 
> TIA
> -- 
> Comp. Eng. Ozan Eren BILGEN
> 
> TUBITAK - UEKAE (Turkey)
> National Research Institute of Electronics & Cryptology
> Special Projects Group
> Researcher
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

Thanks, Romain.
-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* True story: "gconfig" removed root folder...
  2004-01-15 15:05 ` Roman Zippel
  2004-01-15 15:20   ` Doug McNaught
@ 2004-01-15 21:23   ` Romain Lievin
  2004-01-15 21:46     ` Roman Zippel
  1 sibling, 1 reply; 34+ messages in thread
From: Romain Lievin @ 2004-01-15 21:23 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Linux Kernel Mailing List, Ozan Eren Bilgen

Hi,

> Hi,
> 
> I only did a quick check with menuconfig. Are you sure it's really
> removed? It should still be there as "/root.old".
> I probably should change the behaviour of the save routine to behave
> differently for directories as argument, but it doesn't remove it.

I have managed to reproduce bug: make gconfig, go to the '/' directory,
type 'root' as file and ... you get a 'root' file. The 'root' directory is
destroyed !

> (Changing gconfig to only accept files in the save request would probably
> be nice too...)

I am preparing a patch for gconf so that it can be protected against this bug.
Perhaps, you should protect 'conf_write(fn)', too ?

> 
> bye, Roman
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Romain Liévin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH] "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
                   ` (2 preceding siblings ...)
  2004-01-15 21:05 ` Romain Lievin
@ 2004-01-15 21:44 ` Romain Lievin
  2004-01-16 20:17   ` [PATCH] Bug in patch of Romain: " oebilgen
                     ` (2 more replies)
  2004-01-18 14:21 ` True story: " Romain Lievin
  2004-01-21 19:54 ` [PATCH] " Romain Lievin
  5 siblings, 3 replies; 34+ messages in thread
From: Romain Lievin @ 2004-01-15 21:44 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: Linux Kernel Mailing List, Roman Zippel

Hi,

> Today I downloaded 2.6.1 kernel and tried to configure it with "make
> gconfig". After all changes I selected "Save As" and clicked "/root"
> folder to save in. Then I clicked "OK", without giving a file name. I
> expected that it opens root folder and lists contents. But this magic
> configurator removed (rm -Rf) my root folder and created a file named
> "root". It was a terrible experience!..

A patch against 2.6.1 which fix this problem. Please apply...

Thanks, Romain

===========================[cut here]==========================
diff -Naur linux-2.6.1/scripts/kconfig/gconf.c linux/scripts/kconfig/gconf.c
--- linux-2.6.1/scripts/kconfig/gconf.c	2004-01-15 21:45:22.000000000 +0100
+++ linux/scripts/kconfig/gconf.c	2004-01-15 22:36:55.000000000 +0100
@@ -23,6 +23,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 
 //#define DEBUG
 
@@ -643,9 +646,18 @@
 store_filename(GtkFileSelection * file_selector, gpointer user_data)
 {
 	const gchar *fn;
+	gchar trailing;
+	struct stat sb;
 
 	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
 					     (user_data));
+	
+	/* protect against 'root directory' bug */
+	trailing = fn[strlen(fn)-1];
+	if(stat(fn, &sb) == -1) return;	
+	if(S_ISDIR(sb.st_mode))
+		if(trailing != '/')
+			strcat((char *)fn, "/");
 
 	if (conf_write(fn))
 		text_insert_msg("Error", "Unable to save configuration !");

-- 
Romain Liévin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 21:23   ` Romain Lievin
@ 2004-01-15 21:46     ` Roman Zippel
  2004-01-15 22:00       ` Andreas Tolfsen
  2004-01-16  7:43       ` Romain Lievin
  0 siblings, 2 replies; 34+ messages in thread
From: Roman Zippel @ 2004-01-15 21:46 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Linux Kernel Mailing List, Ozan Eren Bilgen

Hi,

On Thu, 15 Jan 2004, Romain Lievin wrote:

> I have managed to reproduce bug: make gconfig, go to the '/' directory,
> type 'root' as file and ... you get a 'root' file. The 'root' directory is
> destroyed !

What do you mean with "destroyed"? All I can reproduce here is that it's
simply moved away, but it's still there!

bye, Roman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 21:46     ` Roman Zippel
@ 2004-01-15 22:00       ` Andreas Tolfsen
  2004-01-15 22:56         ` Roman Zippel
  2004-01-16  7:43       ` Romain Lievin
  1 sibling, 1 reply; 34+ messages in thread
From: Andreas Tolfsen @ 2004-01-15 22:00 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kernel

Roman Zippel wrote:

> Hi,
> 
> On Thu, 15 Jan 2004, Romain Lievin wrote:
> 
>>I have managed to reproduce bug: make gconfig, go to the '/' directory,
>>type 'root' as file and ... you get a 'root' file. The 'root' directory is
>>destroyed !
> 
> 
> What do you mean with "destroyed"? All I can reproduce here is that it's
> simply moved away, but it's still there!

Is it supposed to be moved away?  I'm just being curious...




^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 22:00       ` Andreas Tolfsen
@ 2004-01-15 22:56         ` Roman Zippel
  2004-01-16  6:39           ` Andreas Tolfsen
  0 siblings, 1 reply; 34+ messages in thread
From: Roman Zippel @ 2004-01-15 22:56 UTC (permalink / raw)
  To: Andreas Tolfsen; +Cc: linux-kernel

Hi,

On Thu, 15 Jan 2004, Andreas Tolfsen wrote:

> > What do you mean with "destroyed"? All I can reproduce here is that it's
> > simply moved away, but it's still there!
>
> Is it supposed to be moved away?  I'm just being curious...

Yes, this usually produces ".config.old", but there is nowhere a "rm -Rf"
as the initial mail suggests.

bye, Roman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 22:56         ` Roman Zippel
@ 2004-01-16  6:39           ` Andreas Tolfsen
  0 siblings, 0 replies; 34+ messages in thread
From: Andreas Tolfsen @ 2004-01-16  6:39 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kernel

Roman Zippel wrote:

> On Thu, 15 Jan 2004, Andreas Tolfsen wrote:
> 
> 
>>>What do you mean with "destroyed"? All I can reproduce here is that it's
>>>simply moved away, but it's still there!
>>
>>Is it supposed to be moved away?  I'm just being curious...
> 
> 
> Yes, this usually produces ".config.old", but there is nowhere a "rm -Rf"
> as the initial mail suggests.
> 

I see, thank you!  That makes more sense!




^ permalink raw reply	[flat|nested] 34+ messages in thread

* True story: "gconfig" removed root folder...
  2004-01-15 21:46     ` Roman Zippel
  2004-01-15 22:00       ` Andreas Tolfsen
@ 2004-01-16  7:43       ` Romain Lievin
  2004-01-16 21:18         ` Doug McNaught
  2004-01-16 21:44         ` Roman Zippel
  1 sibling, 2 replies; 34+ messages in thread
From: Romain Lievin @ 2004-01-16  7:43 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Linux Kernel Mailing List

Hi,

On Thu, Jan 15, 2004 at 10:46:48PM +0100, Roman Zippel wrote:
> Hi,
> 
> On Thu, 15 Jan 2004, Romain Lievin wrote:
> 
> > I have managed to reproduce bug: make gconfig, go to the '/' directory,
> > type 'root' as file and ... you get a 'root' file. The 'root' directory is
> > destroyed !
> 
> What do you mean with "destroyed"? All I can reproduce here is that it's
> simply moved away, but it's still there!

I mean "destroyed" because my 'root' directory did not exist anymore. When I do
a 'ls', I just see a 'root' file with config within.
Well, "destroyed" may not be the best word. I can tell that it vanished somewhere.
Anyways, I don't have any '*.old' file or directory after that.

> bye, Roman

Romain.
-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:20   ` Doug McNaught
  2004-01-15 15:37     ` Erik Hensema
@ 2004-01-16 17:20     ` Max Valdez
  1 sibling, 0 replies; 34+ messages in thread
From: Max Valdez @ 2004-01-16 17:20 UTC (permalink / raw)
  To: Doug McNaught; +Cc: Roman Zippel, Ozan Eren Bilgen, kernel

[-- Attachment #1: Type: text/plain, Size: 1835 bytes --]

I rather have my /root dir removed (nothing there), than my user home,
that would be very bad for me

Max

On Thu, 2004-01-15 at 09:20, Doug McNaught wrote:
> Roman Zippel <zippel@linux-m68k.org> writes:
> 
> > On Thu, 15 Jan 2004, Ozan Eren Bilgen wrote:
> >
> >> Today I downloaded 2.6.1 kernel and tried to configure it with "make
> >> gconfig". After all changes I selected "Save As" and clicked "/root"
> >> folder to save in. Then I clicked "OK", without giving a file name. I
> >> expected that it opens root folder and lists contents. But this magic
> >> configurator removed (rm -Rf) my root folder and created a file named
> >> "root". It was a terrible experience!..
> >
> > I only did a quick check with menuconfig. Are you sure it's really
> > removed? It should still be there as "/root.old".
> > I probably should change the behaviour of the save routine to behave
> > differently for directories as argument, but it doesn't remove it.
> > (Changing gconfig to only accept files in the save request would probably
> > be nice too...)
> 
> The real lesson here is "don't compile your kernel as root".  There's
> no need to do so.
> 
> -Doug
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
-- 
Linux garaged 2.6.1-mm1 #3 SMP Sat Jan 10 13:18:40 CST 2004 i686 Pentium III (Coppermine) GenuineIntel GNU/Linux
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GS/S d- s: a-29 C++(+++) ULAHI+++ P+ L++>+++ E--- W++ N* o-- K- w++++ O- M-- V-- PS+ PE Y-- PGP++ t- 5- X+ R tv++ b+ DI+++ D- G++ e++ h+ r+ z**
------END GEEK CODE BLOCK------
gpg-key: http://garaged.homeip.net/gpg-key.txt

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH] Bug in patch of  Romain: "gconfig" removed root folder...
  2004-01-15 21:44 ` [PATCH] " Romain Lievin
@ 2004-01-16 20:17   ` oebilgen
  2004-01-16 20:32     ` [PATCH] Bug in patch of Romain: "gconfig" remo ved r=?iso-8859-9?Q?Romain: "gconfig" removed=A0root=A0folder..._?= (part 2) oebilgen
  2004-01-16 21:56   ` [PATCH] "gconfig" removed root folder Roman Zippel
       [not found]   ` <20040116161440.GC30349@louise.pinerecords.com>
  2 siblings, 1 reply; 34+ messages in thread
From: oebilgen @ 2004-01-16 20:17 UTC (permalink / raw)
  To: Romain Lievin; +Cc: linux-kernel

Hi again,


Romain, I guess that there will be a segmentation fault because of:

   strcat((char *)fn, "/");

because:

   fn + strlen (fn) + 1

is not allocated for "fn" and strcat(3) may fail (may fail: It might
escape from segfault if gtk_file_selection_get_filename() has an indolent
allocation strategy for fn - like in "Vector" class of C++). It still is a
bug.

Try this. And Romain, this was my first patch (and also first bug report)
for linux-kernel, THX for your hint. I would lose too much time in order
to find store_file@linux-2.6.1/scripts/kconfig/gconf.c ;)


NOTE: I combined mine and Romain's patch, *** DO NOT APPLY BOTH *** !!!

--- scripts/kconfig/gconf.c	2004-01-09 09:00:03.000000000 +0200
+++ scripts/kconfig/gconf-oebilgen_and_romain.c	2004-01-16
21:32:26.000000000 +0200
@@ -23,6 +23,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+

 //#define DEBUG

@@ -643,13 +646,29 @@
 store_filename(GtkFileSelection * file_selector, gpointer user_data)
 {
 	const gchar *fn;
+	gchar trailing, *safefn;
+	struct stat sb;

 	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
 					     (user_data));

-	if (conf_write(fn))
+	/* protect against 'root directory' bug */
+	trailing = fn[strlen(fn)-1];
+	if(stat(fn, &sb) == -1)
+		return;
+	if(S_ISDIR(sb.st_mode))
+		if(trailing != '/')
+		{
+			safefn = (gchar *) malloc (strlen (fn) + 2);
+			strcpy ((char *) safefn, (char *) fn);
+			strcat ((char *) safefn, "/");
+                }
+
+	if (conf_write(safefn))
 		text_insert_msg("Error", "Unable to save configuration !");

+	free (safefn);
+
 	gtk_widget_destroy(GTK_WIDGET(user_data));
 }


To Doug McNaught and "viro"; running gconf as root it is not a must of
course but one couldn't be punished that hard. If you run gconf as normal
user, you still may experience this (a user friendly bug :P) by loosing
your (home) folders...


BTW, I looked to conf_write and saw that its char arrays are very
dangerous. I will hack it on monday, if possible. ("Open source groups are
like mafia; you can join but cannot leave")


THX in advance,

Comp. Eng. Ozan Eren BILGEN

TUBITAK - UEKAE (Turkey)
National Research Institute of Electronics & Cryptology
Special Projects Group
Researcher


> Hi,
>
>> Today I downloaded 2.6.1 kernel and tried to configure it with "make
>> gconfig". After all changes I selected "Save As" and clicked "/root"
>> folder to save in. Then I clicked "OK", without giving a file name. I
>> expected that it opens root folder and lists contents. But this magic
>> configurator removed (rm -Rf) my root folder and created a file named
>> "root". It was a terrible experience!..
>
> A patch against 2.6.1 which fix this problem. Please apply...
>
> Thanks, Romain
>
> ===========================[cut here]=========================diff -Naur
> linux-2.6.1/scripts/kconfig/gconf.c linux/scripts/kconfig/gconf.c
> --- linux-2.6.1/scripts/kconfig/gconf.c	2004-01-15 21:45:22.000000000
> +0100
> +++ linux/scripts/kconfig/gconf.c	2004-01-15 22:36:55.000000000 +0100
> @@ -23,6 +23,9 @@
>  #include <unistd.h>
>  #include <time.h>
>  #include <stdlib.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
>
>  //#define DEBUG
>
> @@ -643,9 +646,18 @@
>  store_filename(GtkFileSelection * file_selector, gpointer user_data)
>  {
>  	const gchar *fn;
> +	gchar trailing;
> +	struct stat sb;
>
>  	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
>  					     (user_data));
> +
> +	/* protect against 'root directory' bug */
> +	trailing = fn[strlen(fn)-1];
> +	if(stat(fn, &sb) == -1) return;
> +	if(S_ISDIR(sb.st_mode))
> +		if(trailing != '/')
> +			strcat((char *)fn, "/");
>
>  	if (conf_write(fn))
>  		text_insert_msg("Error", "Unable to save configuration !");
>
> --
> Romain Liévin (roms):         <roms@tilp.info>
> Web site:                     http://tilp.info
> "Linux, y'a moins bien mais c'est plus cher !"
>
>



^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re:  [PATCH] Bug in patch of Romain: "gconfig" remo ved r=?iso-8859-9?Q?Romain: "gconfig" removed=A0root=A0folder..._?= (part 2)
  2004-01-16 20:17   ` [PATCH] Bug in patch of Romain: " oebilgen
@ 2004-01-16 20:32     ` oebilgen
  0 siblings, 0 replies; 34+ messages in thread
From: oebilgen @ 2004-01-16 20:32 UTC (permalink / raw)
  To: linux-kernel

Forgotten to please to CC me your comments.

-- OE.



^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-16  7:43       ` Romain Lievin
@ 2004-01-16 21:18         ` Doug McNaught
  2004-01-16 21:44         ` Roman Zippel
  1 sibling, 0 replies; 34+ messages in thread
From: Doug McNaught @ 2004-01-16 21:18 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Roman Zippel, Linux Kernel Mailing List

Romain Lievin <romain@rlievin.dyndns.org> writes:

> I mean "destroyed" because my 'root' directory did not exist anymore. When I do
> a 'ls', I just see a 'root' file with config within.

Try 'ls -a' -- it sounds like the old one is being renamed to a name
that starts with a dot.

-Doug

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-16  7:43       ` Romain Lievin
  2004-01-16 21:18         ` Doug McNaught
@ 2004-01-16 21:44         ` Roman Zippel
  2004-01-18 12:59           ` Romain Lievin
  1 sibling, 1 reply; 34+ messages in thread
From: Roman Zippel @ 2004-01-16 21:44 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Linux Kernel Mailing List

Hi,

On Fri, 16 Jan 2004, Romain Lievin wrote:

> > What do you mean with "destroyed"? All I can reproduce here is that it's
> > simply moved away, but it's still there!
>
> I mean "destroyed" because my 'root' directory did not exist anymore. When I do
> a 'ls', I just see a 'root' file with config within.
> Well, "destroyed" may not be the best word. I can tell that it vanished somewhere.
> Anyways, I don't have any '*.old' file or directory after that.

It would be nice if you could try to find out, what exactly happens with
the directory, the save routine does only a rename...

bye, Roman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH] "gconfig" removed root folder...
  2004-01-15 21:44 ` [PATCH] " Romain Lievin
  2004-01-16 20:17   ` [PATCH] Bug in patch of Romain: " oebilgen
@ 2004-01-16 21:56   ` Roman Zippel
       [not found]   ` <20040116161440.GC30349@louise.pinerecords.com>
  2 siblings, 0 replies; 34+ messages in thread
From: Roman Zippel @ 2004-01-16 21:56 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Ozan Eren Bilgen, Linux Kernel Mailing List

Hi,

On Thu, 15 Jan 2004, Romain Lievin wrote:

>  	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
>  					     (user_data));
> +
> +	/* protect against 'root directory' bug */
> +	trailing = fn[strlen(fn)-1];
> +	if(stat(fn, &sb) == -1) return;
> +	if(S_ISDIR(sb.st_mode))
> +		if(trailing != '/')
> +			strcat((char *)fn, "/");
>
>  	if (conf_write(fn))
>  		text_insert_msg("Error", "Unable to save configuration !");

Um, I thought gtk++ also had an option that prevents the selection of
directories.
A test like this should be added to conf_write().

bye, Roman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-15 15:37     ` Erik Hensema
  2004-01-15 16:07       ` Tim Cambrant
@ 2004-01-17 16:47       ` Alban Browaeys
  1 sibling, 0 replies; 34+ messages in thread
From: Alban Browaeys @ 2004-01-17 16:47 UTC (permalink / raw)
  To: linux-kernel


> Yes, having your user homedirectory removed is *much* better :-)

Isn t the policy as of administrator to use a test and an admin account ;
The former as a compile and check account the latter with installation
privilege.

Sure the process is left as administrator responsability but could this
sane behaviour be implmeented in distribution as part of source package
 installation.

Alban


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH] "gconfig" removed root folder...
       [not found]   ` <20040116161440.GC30349@louise.pinerecords.com>
@ 2004-01-17 21:47     ` Romain Lievin
  2004-01-18  7:24       ` Tomas Szepe
  0 siblings, 1 reply; 34+ messages in thread
From: Romain Lievin @ 2004-01-17 21:47 UTC (permalink / raw)
  To: Tomas Szepe; +Cc: Linux Kernel Mailing List

Hi,

On Fri, Jan 16, 2004 at 05:14:41PM +0100, Tomas Szepe wrote:
> On Jan-15 2004, Thu, 22:44 +0100
> Romain Lievin <romain@rlievin.dyndns.org> wrote:
> 
> > +	if(stat(fn, &sb) == -1) return;	
> 
> Codingstyle inconsistency.

What should I write then ? Your piece of advice may make me better.

> 
> Contrary to popular belief, 'if' is _not_ a function nor is it a macro.

Thanks, Romain.
-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH] "gconfig" removed root folder...
  2004-01-17 21:47     ` Romain Lievin
@ 2004-01-18  7:24       ` Tomas Szepe
  0 siblings, 0 replies; 34+ messages in thread
From: Tomas Szepe @ 2004-01-18  7:24 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Linux Kernel Mailing List

On Jan-17 2004, Sat, 22:47 +0100
Romain Lievin <romain@rlievin.dyndns.org> wrote:

> > On Jan-15 2004, Thu, 22:44 +0100
> > Romain Lievin <romain@rlievin.dyndns.org> wrote:
> > 
> > > +	if(stat(fn, &sb) == -1) return;	
> > 
> > Codingstyle inconsistency.
> 
> What should I write then ? Your piece of advice may make me better.

Read Documentation/CodingStyle.  It is loosely based on the original
K&R style, where (the scarce) language constructs' arguments' opening
parenthese is prepended by a space, whereas with functions and macros
it is not.  I.e., one writes 'if (...)', 'while (...)', 'foo(bar)', etc.

Also, your explicit casts could use extra whitespace, like so:
"a = (int *) b;" not "a = (int *)b;"

When submiting code to an existing file, the general rule of thumb
is not to disrupt the style of that particular file, regardless
of what it appears to be.  You have managed to break this rule
_and_ the official CodingStyle.

-- 
Tomas Szepe <szepe@pinerecords.com>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* True story: "gconfig" removed root folder...
  2004-01-16 21:44         ` Roman Zippel
@ 2004-01-18 12:59           ` Romain Lievin
  0 siblings, 0 replies; 34+ messages in thread
From: Romain Lievin @ 2004-01-18 12:59 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Linux Kernel Mailing List

Hi,

On Fri, Jan 16, 2004 at 10:44:55PM +0100, Roman Zippel wrote:
> > I mean "destroyed" because my 'root' directory did not exist anymore. When I do
> > a 'ls', I just see a 'root' file with config within.
> > Well, "destroyed" may not be the best word. I can tell that it vanished somewhere.
> > Anyways, I don't have any '*.old' file or directory after that.
> 
> It would be nice if you could try to find out, what exactly happens with
> the directory, the save routine does only a rename...

You're right ! The save routine does on ly a rename. My 'root' directory is simply moved to 'root.old'.

Given that all stuffs are clear now, I'm preparing a patch for this.

> 
> bye, Roman

Thanks, Romain.
-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* True story: "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
                   ` (3 preceding siblings ...)
  2004-01-15 21:44 ` [PATCH] " Romain Lievin
@ 2004-01-18 14:21 ` Romain Lievin
  2004-01-18 14:32   ` Muli Ben-Yehuda
  2004-01-21 19:54 ` [PATCH] " Romain Lievin
  5 siblings, 1 reply; 34+ messages in thread
From: Romain Lievin @ 2004-01-18 14:21 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: Linux Kernel Mailing List

Hi,

a patch for gconfig against kernel2.6.1.

Thanks to Tomas and Ozan.

Romain.

================ [ cut here ] ===========
diff -Naur linux-2.6.1/scripts/kconfig/gconf.c linux/scripts/kconfig/gconf.c
--- linux-2.6.1/scripts/kconfig/gconf.c	2004-01-15 21:45:22.000000000 +0100
+++ linux/scripts/kconfig/gconf.c	2004-01-18 15:15:23.000000000 +0100
@@ -23,6 +23,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 
 //#define DEBUG
 
@@ -643,14 +646,29 @@
 store_filename(GtkFileSelection * file_selector, gpointer user_data)
 {
 	const gchar *fn;
+	gchar trailing;
+	gchar *safe_fn;
+	struct stat sb;
 
-	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
+	fn = gtk_file_selection_get_filename (GTK_FILE_SELECTION
 					     (user_data));
 
-	if (conf_write(fn))
-		text_insert_msg("Error", "Unable to save configuration !");
+	/* protect against 'root directory' bug */
+	trailing = fn[strlen (fn)-1];
+	stat (fn, &sb);
+	safe_fn = g_strdup (fn);
+
+	if (S_ISDIR(sb.st_mode))
+		if (trailing != '/')
+		{
+			g_free (safe_fn);
+			safe_fn = g_strconcat (fn, "/", NULL);
+		}
 
-	gtk_widget_destroy(GTK_WIDGET(user_data));
+	if (conf_write (safe_fn))
+		text_insert_msg("Error", "Unable to save configuration !");
+	g_free (safe_fn);
+	gtk_widget_destroy (GTK_WIDGET(user_data));
 }
 
 void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)

-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: True story: "gconfig" removed root folder...
  2004-01-18 14:21 ` True story: " Romain Lievin
@ 2004-01-18 14:32   ` Muli Ben-Yehuda
  0 siblings, 0 replies; 34+ messages in thread
From: Muli Ben-Yehuda @ 2004-01-18 14:32 UTC (permalink / raw)
  To: Romain Lievin; +Cc: Ozan Eren Bilgen, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 449 bytes --]

On Sun, Jan 18, 2004 at 03:21:48PM +0100, Romain Lievin wrote:

> -	if (conf_write(fn))
> -		text_insert_msg("Error", "Unable to save configuration !");
> +	/* protect against 'root directory' bug */
> +	trailing = fn[strlen (fn)-1];
> +	stat (fn, &sb);

What if stat() fails? 

Cheers, 
Muli 
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

"the nucleus of linux oscillates my world" - gccbot@#offtopic


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH] "gconfig" removed root folder...
  2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
                   ` (4 preceding siblings ...)
  2004-01-18 14:21 ` True story: " Romain Lievin
@ 2004-01-21 19:54 ` Romain Lievin
  5 siblings, 0 replies; 34+ messages in thread
From: Romain Lievin @ 2004-01-21 19:54 UTC (permalink / raw)
  To: Ozan Eren Bilgen; +Cc: Linux Kernel Mailing List, Roman Zippel

Hi,

This new patch includes Muli's remarks.
Need to be applied against a 2.6.1 kernel.

Thanks, Romain.
==========================[ cut here]==========================
diff -Naur linux-2.6.1/scripts/kconfig/gconf.c linux/scripts/kconfig/gconf.c
--- linux-2.6.1/scripts/kconfig/gconf.c	2004-01-15 21:45:22.000000000 +0100
+++ linux/scripts/kconfig/gconf.c	2004-01-21 20:48:04.000000000 +0100
@@ -23,6 +23,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 
 //#define DEBUG
 
@@ -643,14 +646,29 @@
 store_filename(GtkFileSelection * file_selector, gpointer user_data)
 {
 	const gchar *fn;
+	gchar trailing;
+	gchar *safe_fn;
+	struct stat sb;
 
-	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
+	fn = gtk_file_selection_get_filename (GTK_FILE_SELECTION
 					     (user_data));
 
-	if (conf_write(fn))
-		text_insert_msg("Error", "Unable to save configuration !");
+	/* protect against 'root directory' bug */
+	trailing = fn[strlen (fn)-1];
+	safe_fn = g_strdup (fn);
+
+	if(!stat (fn, &sb))
+		if (S_ISDIR(sb.st_mode))
+			if (trailing != '/')
+			{
+				g_free (safe_fn);
+				safe_fn = g_strconcat (fn, "/", NULL);
+			}
 
-	gtk_widget_destroy(GTK_WIDGET(user_data));
+	if (conf_write (safe_fn))
+		text_insert_msg("Error", "Unable to save configuration !");
+	g_free (safe_fn);
+	gtk_widget_destroy (GTK_WIDGET(user_data));
 }
 
 void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)

-- 
Romain Li�vin (roms):         <roms@tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"







^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2004-01-21 19:54 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-15 14:36 True story: "gconfig" removed root folder Ozan Eren Bilgen
2004-01-15 15:05 ` Roman Zippel
2004-01-15 15:20   ` Doug McNaught
2004-01-15 15:37     ` Erik Hensema
2004-01-15 16:07       ` Tim Cambrant
2004-01-15 16:17         ` Valdis.Kletnieks
2004-01-15 18:31           ` Tim Cambrant
2004-01-15 18:49             ` Valdis.Kletnieks
2004-01-15 19:00             ` Richard B. Johnson
2004-01-15 19:30               ` Valdis.Kletnieks
2004-01-15 19:48               ` Erik Hensema
2004-01-17 16:47       ` Alban Browaeys
2004-01-16 17:20     ` Max Valdez
2004-01-15 21:23   ` Romain Lievin
2004-01-15 21:46     ` Roman Zippel
2004-01-15 22:00       ` Andreas Tolfsen
2004-01-15 22:56         ` Roman Zippel
2004-01-16  6:39           ` Andreas Tolfsen
2004-01-16  7:43       ` Romain Lievin
2004-01-16 21:18         ` Doug McNaught
2004-01-16 21:44         ` Roman Zippel
2004-01-18 12:59           ` Romain Lievin
2004-01-15 15:40 ` viro
2004-01-15 16:01   ` Jan-Benedict Glaw
2004-01-15 21:05 ` Romain Lievin
2004-01-15 21:44 ` [PATCH] " Romain Lievin
2004-01-16 20:17   ` [PATCH] Bug in patch of Romain: " oebilgen
2004-01-16 20:32     ` [PATCH] Bug in patch of Romain: "gconfig" remo ved r=?iso-8859-9?Q?Romain: "gconfig" removed=A0root=A0folder..._?= (part 2) oebilgen
2004-01-16 21:56   ` [PATCH] "gconfig" removed root folder Roman Zippel
     [not found]   ` <20040116161440.GC30349@louise.pinerecords.com>
2004-01-17 21:47     ` Romain Lievin
2004-01-18  7:24       ` Tomas Szepe
2004-01-18 14:21 ` True story: " Romain Lievin
2004-01-18 14:32   ` Muli Ben-Yehuda
2004-01-21 19:54 ` [PATCH] " Romain Lievin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).