2004-01-15 14:37:32

by Ozan Eren Bilgen

[permalink] [raw]
Subject: True story: "gconfig" removed root folder...

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



2004-01-15 15:06:44

by Roman Zippel

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

2004-01-15 15:21:16

by Douglas McNaught

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

Roman Zippel <[email protected]> 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

2004-01-15 15:40:47

by Al Viro

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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?

2004-01-15 15:37:14

by Erik Hensema

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

Doug McNaught ([email protected]) wrote:
> Roman Zippel <[email protected]> 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 <[email protected]>

2004-01-15 16:08:17

by Tim Cambrant

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

2004-01-15 16:01:45

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

On Thu, 2004-01-15 15:40:39 +0000, [email protected] <[email protected]>
wrote in message <[email protected]>:
> 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 [email protected] . +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));


Attachments:
(No filename) (746.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-01-15 16:18:21

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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.


Attachments:
(No filename) (226.00 B)

2004-01-15 18:31:31

by Tim Cambrant

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

On Thu, Jan 15, 2004 at 11:17:32AM -0500, [email protected] 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

2004-01-15 18:49:13

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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 ;)


Attachments:
(No filename) (226.00 B)

2004-01-15 18:57:38

by Richard B. Johnson

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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.

2004-01-15 19:31:08

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

:)


Attachments:
(No filename) (226.00 B)

2004-01-15 19:48:26

by Erik Hensema

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

Richard B. Johnson ([email protected]) 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 <[email protected]>

2004-01-15 21:06:44

by Romain Lievin

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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 [email protected]
> 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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-15 21:23:15

by Romain Lievin

[permalink] [raw]
Subject: True story: "gconfig" removed root folder...

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 [email protected]
> 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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-15 21:47:03

by Roman Zippel

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

2004-01-15 21:44:20

by Romain Lievin

[permalink] [raw]
Subject: [PATCH] "gconfig" removed root folder...

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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-15 22:00:28

by Andreas Tolfsen

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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...



2004-01-15 22:58:33

by Roman Zippel

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

2004-01-16 06:39:17

by Andreas Tolfsen

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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!



2004-01-16 07:43:46

by Romain Lievin

[permalink] [raw]
Subject: True story: "gconfig" removed root folder...

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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-16 17:21:53

by Max Valdez

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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 <[email protected]> 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 [email protected]
> 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


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2004-01-16 20:17:38

by Ozan Eren Bilgen

[permalink] [raw]
Subject: [PATCH] Bug in patch of Romain: "gconfig" removed root folder...

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 [email protected]/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): <[email protected]>
> Web site: http://tilp.info
> "Linux, y'a moins bien mais c'est plus cher !"
>
>


2004-01-16 21:19:19

by Douglas McNaught

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

Romain Lievin <[email protected]> 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

2004-01-16 22:11:23

by Roman Zippel

[permalink] [raw]
Subject: Re: [PATCH] "gconfig" removed root folder...

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

2004-01-16 22:04:56

by Roman Zippel

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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

2004-01-18 12:59:36

by Romain Lievin

[permalink] [raw]
Subject: True story: "gconfig" removed root folder...

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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-18 14:21:53

by Romain Lievin

[permalink] [raw]
Subject: True story: "gconfig" removed root folder...

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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






2004-01-18 14:33:07

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...

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


Attachments:
(No filename) (431.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-01-18 16:30:15

by Alban Browaeys

[permalink] [raw]
Subject: Re: True story: "gconfig" removed root folder...


> 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

2004-01-21 19:54:17

by Romain Lievin

[permalink] [raw]
Subject: [PATCH] "gconfig" removed root folder...

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): <[email protected]>
Web site: http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"