Bug 88531 - dangerous code ''rm''
Summary: dangerous code ''rm''
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: postfix
Version: 1.0
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: John Dennis
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-04-10 18:12 UTC by acount closed by user
Modified: 2007-04-18 16:52 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-06-13 15:11:58 UTC
Embargoed:


Attachments (Terms of Use)

Description acount closed by user 2003-04-10 18:12:17 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.6 (X11; Linux i686; U;) Gecko/20020913

Description of problem:
I don't like this funtion into %preun.
It is very dangerous to use _rm_ for delete queues dirs and  It is possible lost
mail!!!
I would like see that rpm delete them (if it can -> empty dirs) automatically
and not by hand.


-thanks-

# selectively remove the rest of the queue directory structure
# first remove the "queues" (and assume the hash depth is still 2)
queue_directory_remove () {
    for dir in active bounce defer deferred flush incoming; do
        for a in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do
            test -d $dir/$a && {
                for b in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do
                    test -d $dir/$a/$b && (
                        /bin/rm -f $dir/$a/$b/*
                        /bin/rmdir $dir/$a/$b
                    )
                done
                /bin/rmdir $dir/$a || echo "WARNING: preun - unable to remove
directory %{_var}/spool/postfix/$dir/$a"
            }
        done
        /bin/rmdir $dir || echo "WARNING: preun - unable to remove directory
%{_var}/spool/postfix/$dir"
    done

    # now remove the other directories
    for dir in corrupt maildrop pid private public saved; do
        test -d $dir && {
            /bin/rm -f $dir/*
            /bin/rmdir $dir || echo "WARNING: preun - unable to remove directory
%{_var}/spool/postfix/$dir"
        }
    done
}


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.-
2.-
3.-
    

Additional info:

Comment 1 John Dennis 2003-06-12 15:01:11 UTC
I'm not 100% sure I understand what you are asking for. Is your suggestion not
to remove a queue directory if its not empty or are you saying not to remove any
of the queue directories? Why would that be the proper uninstall behavior?

If one is uninstalling postfix as opposed to upgrading then why is the loss of
mail left in queue that will never be accessed again an issue?

Comment 2 acount closed by user 2003-06-12 15:45:57 UTC
>I'm not 100% sure I understand what you are asking for. Is your suggestion not
to remove a queue directory if its not empty or are you saying not to remove any
of the queue directories? Why would that be the proper uninstall behavior?

It means "doesn't delete any file or dir placing *rm* code into a spec file"
rpm knowns how to handle it automatically, this is a job for %files section

>If one is uninstalling postfix as opposed to upgrading then why is the loss of
mail left in queue that will never be accessed again an issue?

because to delete a file/dir, which was *not into the rpm package*, is very bad
rule. And worse if it delete mail!!!


-thanks-

Comment 5 John Dennis 2003-06-12 18:41:48 UTC
I will make the change if you can provide a reasonable argument as to why the
queue directories and their contents are of value after removing postfix from
the machine, any mail that is stuck there will never be processed anyway. Fair
enough?

Comment 6 acount closed by user 2003-06-12 22:27:49 UTC
>I will make the change if you can provide a reasonable argument as to why the

ok I will do:
- to delete files not in possession of a package is a dangerous/bad habit.
- no other rpm package use rm to delete files or dirs, 'rpm' knows how to do it
_automatically_. rpm is *the* package management!! 
People hope that, more or less, all rpm packages will have the same behaviour.
Sendmail doesn't delete _any_ queue files. 
rpm saves in a .rpmsave files that have been modified and it's strange that
postix delete files not in his own

>queue directories and their contents are of value after removing postfix from
the machine, any mail that is stuck there will never be processed anyway. 

rpm automatically deletes empty dirs, if rpm is unable to delete them then
directories contain files out of this package. maybe other package or the admin
had created them.

I hope that maintainer of filesystem spec doesn't use rm }:-)






Comment 7 John Dennis 2003-06-13 15:11:58 UTC
I have removed all the code in the spec file which deletes files and directories
duing an uninstall.

Comment 8 acount closed by user 2003-06-14 00:36:58 UTC
thank you


Note You need to log in before you can comment on or make changes to this bug.