Ubuntu QA:
BlogBrainstormPackage status
Log in
Ubuntu QA
The Ubuntu community has contributed 15328 ideas, 75068 comments, 1387413 votes

Idea #8393: create config files automatically if they are deleted



up
125
down
Written by pyrates the 12 May 08 at 01:00. Category: System.
Related to: Nothing/Others. Status: New
Description
In OS X if you delete an applications preferences and then run that application, it will automatically create default preferences for you. Too many applications depend on their configuration files already existing for them to work properly and I think it would really smart if the application checks if its configuration files are set correctly, and if they aren't, to offer to reset them. But if the configuration files aren't even their, then it can automatically create them for you without you having to even indicate it to do that. I really think this would be a smart approach to handling problems on a system where the configuration files are either missing or are incorrectly configured.

Samba is a good example of this. If you delete that smb.conf file, then it can't do anything. If it did this, that would be so awesome.

Certain apps that can't have a default configuration, would instead ask the user by going through a wizard of what they should be.

An example is the iptables app, if it noticed it had no preferences, then it would notify the user to go through a wizard to create default preferences again giving the choice of which default configuration they would want to use. One could be wide open, another could be locked down, and a third would be to import preferences from a file. Either way it would prevent an app from running without preferences being there.

For debugging an app without preferences, there could be a universal option such as --nopref and attempt to load the app when there was no preferences. Since obviously developers would know of this option to call and not end users.

It should not be required by the end user to have to manually edit or create any preferences that an application needs if that application can by default recreate default preferences, or if there is more then one default preference to start out with, give the user the choice of which one they would want to start out with.

These 3 steps should be taken:

1. Check if there are any preferences, if there is some, proceed to 2. If not, go to 1a.
1a. Check if there is only default preferences. If so, recreate them. If there is more then 2 default preferences configurations, step the user through a wizard.
2. Check if preferences are valid and not corrupt, if so, proceed to step 3. If not, proceed to step 2a.
2a. Attempt to repair preferences. If succeeded, go to step 3. If not delete preferences and go to step 1a.
3. Launch application.

Here's an interesting response to when Samba doesn't work with no configs why it takes so bloody long just to remember how to setup your shares again:

http://linuxhaters.blogspot.com/2008/07/of-silos-and-samba.html

If this is for a service, and it includes a configuration file, then there should be a ui for changing that configuration. When that service starts up and it has no configuration file, it should again either automatically create it for you, or send you through a wizard to configure it. But at the same time the configuration file needs to be trimmed down and features in it that only a developer would need should be removed with hard coded defaults. But if a developer wants to change those hard coded defaults, they are free to do that. Either way, it makes the end users life easier. And that is what counts here after all isn't it?
Tags: (none)

Attachments
No attachments.


Duplicates


Comments
gryc wrote on the 12 May 08 at 05:28
X11 has done this for a while though I'm not sure if it actually writes the config it runs with to disk or not. Applications that depend on certain config files being present should have defaults so that it can run if that config file gets corrupted or otherwise deleted. (Though that opens up the issue of it overwriting a legacy semi-bad config file with a pristine one, but that's a corner case.)

+1, all programs should do this.

francois wrote on the 12 May 08 at 09:53
I think most programs already does this, bt your're right, some programs does not create automatically conf file when it is missing (I had problems because of this wih mpd)

mbw wrote on the 12 May 08 at 14:18

I like this idea, but would be puzzled by the behavior if it happened without my knowledge.... sometimes debugging is easier if an app doesnt start or breaks or cant find its config file.

If I create a really good locked down iptables config file, and it disappears - what will the "auto replaced" one look like? Will it be fully locked or wide open? Those are the only 2 defaults I can imagine for a complex tool like that - and both have severe security implications.

I guess I am arguing that certain apps shouldnt do this, but the simple ones used by the most # of users might be good candidates. So userland apps=ok, system apps=not ok

One last comment... the system should email the root user if this happens so the sysadmin can see (if they are paying attention) that a config file was deleted or disappeared.


PeterKraus wrote on the 12 May 08 at 22:46
I like mbw's reply, he pretty much summed it up.

Redrazor39 wrote on the 13 May 08 at 00:20
+1

pyrates wrote on the 15 May 08 at 07:44
Mbw well said. But I still think every app should enable this. Here are my responses to it for the points you brought up:

For your iptables app, if it noticed it had no preferences, then it would notify the user to go through a wizard to create default preferences again giving the choice of which default configuration they would want to use. One could be wide open, another could be locked down, and a third would be to import preferences from a file. Either way it would prevent an app from running without preferences being there.

As for debugging an app without preferences, there could be a universal option such as --nopref and attempt to load the app when there was no preferences. Since obviously developers would know of this option to call and not end users.

It should not be required by the end user to have to manually edit or create any preferences that an application needs if that application can by default recreate default preferences, or if there is more then one default preference to start out with, give the user the choice of which one they would want to start out with.

What's so bad about this?

daengbo wrote on the 26 Jun 08 at 05:35
Mbw made one mistake in that excellent comment: userland apps already do this. Deleting configs in your home folder means that the userland app will write a default config the next time.

I guess a library could be written which looks for failure due to a (missing/corrupted) configuration file and calls "dpkg-reconfigure" for the package to recreate the config file. In this case, an easy default would require no user input while a more complicated config which would likely break would already have --configure questions suited. No need to reinvent everything here.

Apps would then have to be modified to have a hook into the new library. That wouldn't be a small amount of work. It's possible it could be semi-automated, though.

robrwo wrote on the 16 Jul 08 at 14:38
This is not practical for a lot of services (as opposed to applications). You want your daemons to be lean.

Also: if configuration files are getting deleted from /etc, then you've got a serius problem.

Sometimes there is a one-size-fits-all default config, and in these cases it makes sense to have a way of getting it from the package manager (note the risk that if it's upgraded you risk damaging your customised configutation).

Other times a program needs to be run to generate a custom "default" configuration for your system. So it's not an easy problem.

But that gives me an alternative idea....

pyrates wrote on the 23 Jul 08 at 07:48
robrwo, I understand what you're saying. However so many applications and services depend on the configuration being there already, why can't it just be recreated? Surely there must be a default way that the developer intended the application to start out on?

And why would you depend on the package manager of the application storing the default configuration? Why not just program it into the application itself to regenerate that preference? Is it so bad that we make the user's life easier?

medigeek wrote on the 18 Oct 08 at 22:17
Seems like to solve this problem, you have to post a bug for each application separately :)

pyrates wrote on the 22 Oct 08 at 02:20
I filed this because I want it to get started. I think the way Apple did it was the best way to do it.


Post your comment