FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 01-11-2008, 04:52 PM
Till Maas
 
Default Deleting a file/directory on startup

Hiyas,

a package I comaintain (pm-utils) uses a lockfile. Because it may happen that
the computer crashes when the program is used, the lockfile may be there
already when no instance of pm-utils is running. Therefore the lockfile
should be deleted on startup. Do I need to write an initscript for this?
Which is imho not 100% correct, because this "service" should never be
deactivated. Is there a directory , where one could drop a file for this? The
only one I can think of would be /etc/sysconfig/modules, where ever .modules
file is executed at startup. The original feature request to split up
rc.sysinit in a rc.sysinit.d structure is more than five years old (which
would be a good solution here), so I doubt that filing a feature request will
help here. But maybe someone knows a better solution that the two I can think
of.

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-11-2008, 05:32 PM
Till Maas
 
Default Deleting a file/directory on startup

On Fri January 11 2008, Till Maas wrote:

> request will help here. But maybe someone knows a better solution that the
> two I can think of.

Here is my third idea: Use a crontab with @reboot, but this creates a
dependency on cron.

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-11-2008, 05:41 PM
"Jonathan Underwood"
 
Default Deleting a file/directory on startup

On 11/01/2008, Till Maas <opensource@till.name> wrote:
> Hiyas,
>
> a package I comaintain (pm-utils) uses a lockfile. Because it may happen that
> the computer crashes when the program is used, the lockfile may be there
> already when no instance of pm-utils is running. Therefore the lockfile
> should be deleted on startup. Do I need to write an initscript for this?
> Which is imho not 100% correct, because this "service" should never be
> deactivated. Is there a directory , where one could drop a file for this? The
> only one I can think of would be /etc/sysconfig/modules, where ever .modules
> file is executed at startup. The original feature request to split up
> rc.sysinit in a rc.sysinit.d structure is more than five years old (which
> would be a good solution here), so I doubt that filing a feature request will
> help here. But maybe someone knows a better solution that the two I can think
> of.

Have a look at the logic used in the fail2ban init file - the start
operation checks for a running fail2ban process. If non is found, it
is safe to delete the lock file.

As it happens, I just noticed that dovecot doesn't properly handle
this situation either.

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-11-2008, 05:54 PM
John Dennis
 
Default Deleting a file/directory on startup

The usual technique is to write a pid file in /var/run/name.pid. When
the program is started check the running status of the process id found
in the pid file. If it's dead remove the lock file and proceed,
otherwise exit.


--
John Dennis <jdennis@redhat.com>

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-11-2008, 06:01 PM
Till Maas
 
Default Deleting a file/directory on startup

On Fri January 11 2008, Till Maas wrote:
> On Fri January 11 2008, Till Maas wrote:
> > request will help here. But maybe someone knows a better solution that
> > the two I can think of.
>
> Here is my third idea: Use a crontab with @reboot, but this creates a
> dependency on cron.

After I thought more about it, this may only work, when cron is started before
acpid or any other service that may allow the user to suspend the machine.

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-11-2008, 06:03 PM
Till Maas
 
Default Deleting a file/directory on startup

On Fri January 11 2008, Jonathan Underwood wrote:

> Have a look at the logic used in the fail2ban init file - the start
> operation checks for a running fail2ban process. If non is found, it
> is safe to delete the lock file.

The logic in fail2ban is vulnerable to race conditions, which does not help
for pm-utils, where it can easily happen that it is run several times very
fast after each other.

Btw. the initial problem is to only delete a file at startup. I even found a
bug report specifically about this: https://bugzilla.redhat.com/250927

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-14-2008, 06:30 PM
nodata
 
Default Deleting a file/directory on startup

Am Freitag, den 11.01.2008, 20:03 +0100 schrieb Till Maas:
> On Fri January 11 2008, Jonathan Underwood wrote:
>
> > Have a look at the logic used in the fail2ban init file - the start
> > operation checks for a running fail2ban process. If non is found, it
> > is safe to delete the lock file.
>
> The logic in fail2ban is vulnerable to race conditions, which does not help
> for pm-utils, where it can easily happen that it is run several times very
> fast after each other.
>
> Btw. the initial problem is to only delete a file at startup. I even found a
> bug report specifically about this: https://bugzilla.redhat.com/250927
>
> Regards,
> Till
> --
> fedora-devel-list mailing list
> fedora-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-devel-list

The directory that stores these files should be wiped at boot or on
shutdown..

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-14-2008, 06:47 PM
Till Maas
 
Default Deleting a file/directory on startup

On Mon January 14 2008, nodata wrote:

> The directory that stores these files should be wiped at boot or on
> shutdown..

Yes, this is where I search the best way to do this, except that I want that a
directory is deleted. rc.sysinit does this only for some directories
in /var/{run,lock}, e.g. for vmware.

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-14-2008, 09:27 PM
Casey Dahlin
 
Default Deleting a file/directory on startup

Till Maas wrote:

On Mon January 14 2008, nodata wrote:



The directory that stores these files should be wiped at boot or on
shutdown..



Yes, this is where I search the best way to do this, except that I want that a
directory is deleted. rc.sysinit does this only for some directories
in /var/{run,lock}, e.g. for vmware.


Regards,
Till

The most correct way is to put some content in the lockfile to allow it
to be determined if it is valid. Then pm-utils itself can figure it out
when its run.


--CJD

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 
Old 01-15-2008, 10:08 AM
Till Maas
 
Default Deleting a file/directory on startup

On Mon January 14 2008, Casey Dahlin wrote:

> The most correct way is to put some content in the lockfile to allow it
> to be determined if it is valid. Then pm-utils itself can figure it out
> when its run.

How can this be done in a bullet-proof way[1]? Also it seems to be a lot more
complicated than just to make sure, that the lockdirectory is removed on
startup (and there are already a lot of files and directories that are
removed on startup by rc.sysinit, so it is more a common way to do it).
The best way I know would be to be able to identify whether or not a system
was rebooted since a file was created, but given there are systems that do
not have a hardware clock, I do not know of a way to identify it. Is there,
e.g. a file in /proc or /sys that will have a unique content that only
changes every time a system is powered up?

Regards,
Till
--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
 

Thread Tools




All times are GMT. The time now is 12:31 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org