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
Signature · 6 lines
Comp. Eng. Ozan Eren BILGEN TUBITAK - UEKAE (Turkey) National Research Institute of Electronics & Cryptology Special Projects Group Researcher
Hi,
Quoted 6 lines · Ozan Eren Bilgen
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
Quoted 9 lines · Roman Zippel
Quoted 6 lines · Ozan Eren Bilgen
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!..
Quoted 6 lines
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
Quoted 18 lines · Doug McNaught
Quoted 9 lines · Roman Zippel
Quoted 6 lines · Ozan Eren Bilgen
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!..
Quoted 6 lines
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...)
Quoted 2 lines
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 :-)
Signature · 1 line
Erik Hensema <[email protected]>
Quoted 1 line · Erik Hensema
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
Quoted 5 lines · Tim Cambrant
Quoted 1 line · Erik Hensema
Yes, having your user homedirectory removed is *much* better :-)
How about using
/usr/srcand 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.
Quoted 2 lines · 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
Quoted 2 lines · Tim Cambrant
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.
Quoted 2 lines
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 ;)
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.
Quoted 2 lines · Richard B. Johnson
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
:)
Quoted 6 lines · Richard B. Johnson
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.
Signature · 1 line
Erik Hensema <[email protected]>
Quoted 2 lines
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
I rather have my /root dir removed (nothing there), than my user home, that would be very bad for me
Max
Quoted 27 lines · Doug McNaught
Quoted 9 lines · Roman Zippel
Quoted 6 lines · Ozan Eren Bilgen
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!..
Quoted 6 lines
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.
(quoted diff) +0
-2-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/
Signature · 6 lines
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
Hi,
Quoted 6 lines
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 !
Quoted 2 lines
(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 ?
Quoted 7 lines
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/
Signature · 3 lines
Romain Liévin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
Hi,
Quoted 3 lines · Romain Lievin
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
Quoted 11 lines · Roman Zippel
Hi,
Quoted 3 lines · Romain Lievin
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...
Hi,
Quoted 4 lines · Andreas Tolfsen
Quoted 2 lines
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
Quoted 12 lines · Roman Zippel
Quoted 4 lines · Andreas Tolfsen
Quoted 2 lines
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!
Hi,
Quoted 10 lines · Roman Zippel
Hi,
Quoted 3 lines · Romain Lievin
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.
Quoted 1 line
bye, Roman
Romain.
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
Quoted 2 lines · Romain Lievin
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
Hi,
Quoted 7 lines · Romain Lievin
Quoted 2 lines
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
Hi,
Quoted 7 lines · Roman Zippel
Quoted 4 lines
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.
Quoted 2 lines
bye, Roman
Thanks, Romain.
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
Quoted 9 lines · Ozan Eren Bilgen
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!..
Quoted 5 lines
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?
On Thu, 2004-01-15 15:40:39 +0000, [email protected] <[email protected]> wrote in message <[email protected]>:
Quoted 4 lines · Ozan Eren Bilgen
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
Signature · 4 lines
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));
Hi,
Quoted 9 lines · Ozan Eren Bilgen
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.
Quoted 3 lines
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.
Quoted 21 lines
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
Signature · 13 lines
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.
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
PATCH 1/1 "gconfig" removed root folder...
In reply to Ozan Eren BilgenHi,
Quoted 6 lines
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]==========================
scripts/kconfig/gconf.c +12 -0
@@ -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 !" );
Signature · 3 lines
Romain Liévin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
PATCH 1/1 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
Quoted 54 lines
Hi,
Quoted 6 lines
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.clinux/scripts/kconfig/gconf.c
---linux-2.6.1/scripts/kconfig/gconf.c2004-01-15 21:45:22.000000000
+0100
+++linux/scripts/kconfig/gconf.c2004-01-15 22:36:55.000000000 +0100scripts/kconfig/gconf.c +12
-1@@ -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 !"
Re: [PATCH] Bug in patch of Romain: "gconfig" remo ved r=?iso-8859-9?Q?Romain: "gconfig" removed=A0root=A0folder..._?= (part 2)
Forgotten to please to CC me your comments.
-- OE.
Re: [PATCH] "gconfig" removed root folder...
In reply to Romain LievinHi,
scripts/kconfig/gconf.c line 663
Quoted 12 lines · Romain Lievin
scripts/kconfig/gconf.c +7
-0fn =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
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 "gconfig" removed root folder...
Hi,
Quoted 6 lines · Tomas Szepe
scripts/kconfig/gconf.c line 657
Quoted 1 line · On Jan-15 2004, Thu, 22:44 +0100 Romain Lievin <[email protected]>…
scripts/kconfig/gconf.c +1
-0+if (stat (fn, &sb) ==-1 )return ;Codingstyle inconsistency.
What should I write then ? Your piece of advice may make me better.
Quoted 2 lines
Contrary to popular belief, 'if' is _not_ a function nor is it a macro.
Thanks, Romain.
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
Re: [PATCH] "gconfig" removed root folder...
Quoted 8 lines · On Jan-17 2004, Sat, 22:47 +0100 Romain Lievin <[email protected]>…
Quoted 6 lines
scripts/kconfig/gconf.c line 657
Quoted 1 line · On Jan-15 2004, Thu, 22:44 +0100 Romain Lievin <[email protected]>…
scripts/kconfig/gconf.c +1
-0+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.
Signature · 1 line
Tomas Szepe <[email protected]>
Hi,
a patch for gconfig against kernel2.6.1.
Thanks to Tomas and Ozan.
Romain.
================ [ cut here ] ===========
scripts/kconfig/gconf.c +22 -4
@@ -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)
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"
scripts/kconfig/gconf.c line 658
Quoted 5 lines · Romain Lievin
scripts/kconfig/gconf.c +3
-2-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
Signature · 4 lines
Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/ "the nucleus of linux oscillates my world" - gccbot@#offtopic
PATCH 1/1 "gconfig" removed root folder...
In reply to Ozan Eren BilgenHi,
This new patch includes Muli's remarks.
Need to be applied against a 2.6.1 kernel.
Thanks, Romain.
==========================[ cut here]==========================
scripts/kconfig/gconf.c +22 -4
@@ -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)
Signature · 3 lines
Romain Li�vin (roms): <[email protected]> Web site: http://tilp.info "Linux, y'a moins bien mais c'est plus cher !"