Extending fcopy
Michael Tautschnig
tautschn at model.in.tum.de
Sun Dec 10 19:25:46 CET 2006
> Am Freitag, 8. Dezember 2006 16:48 schrieben Sie:
>
> > > > > - some -k/--keep option (which I'd rather call --keep-permissions :-)
> > [...]
> > If a file permission get borked it will never be fixed by an softupdate.
>
> you don't need to use the -k (keep-permissions) option, so spftupdate can fix
> it. But why should it be broken anyway?
>
Never trust your system. Never.
> > In the case that it's not root:root 644 it has in most cases a special
> > reason. If the file is missing there noting to preserve, what to use then?
>
> then use -M, -m or source file permissions as it is right now.
>
I'd say the patch should add 2 warning:
- One to be displayed in case there is destination file
- Anotherone in the man page: WARNING: -k might introduce a security hole in
case the permissions of the destination file have been altered unexpectedly.
Then, well, it's up to the FAI-user to use -k or not.
> > [...]
> > > i tried to use exit code, too:
> > [...]
> > > > this way you can say
> > >
> > > fcopy ... /etc/postgresql && /etc/init.d/postgresql restart || exit 1;
> > >
> > > What do you think about using exit codes? First i sort it's not unix
> > > like, but diff does like this, too.
> >
> > Add $? to your prompt and you'll see that much more apps do it like this ;)
> > So both methods can coexists with file list turned on (or off) with a file
> > an option.
>
> i switched this behaviour now after some tests. My patched fcopy now returns 0
> if no files were changed or 1 if files were changed. I changed because if
> fcopy returns exit code 1 when nothing was changed it was propagated as the
> script exit code. But i am still not sure what is nicer, to return exit code
> 1 if files were changed or return exit code 1 if files were NOT changed.
>
Return codes and fcopy to me is a somewhat strange thing. The current default
behaviour is that preserving a file is treated as an error and a non-zero exit
status is returned.
In my opinion fcopy should only return something other than 0 if an error
occurred. And preserving a file is not an error IMHO.
As such I'd go for the following: Return 0 unless anything inside fcopy (which
includes preinst/postinst) went wrong. To find out, whether files have been
altered or not (which includes changing permissions), I'd prefer an output like
the following (more or less proper perl, but I guess you get the idea):
if( $changed )
{
printf "fcopy is updating $file:\n";
printf "\t Copied $src to $dest\n" if( $copied );
printf "\t Permissions set to $perm\n" if( $perm_changed );
}
Then, one could do the following:
fcopy ... /etc/postgresql | grep -q "fcopy is updating" && /etc/init.d/postgresql restart
Best,
Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://lists.uni-koeln.de/pipermail/linux-fai-devel/attachments/20061210/af795045/attachment.bin
More information about the linux-fai-devel
mailing list