Problem with %attr/%defattr

Jos Vos jos at
Fri Oct 7 12:57:17 UTC 2011

On Fri, Oct 07, 2011 at 06:11:15PM +0530, Amol Kulkarni wrote:

> The qmail makefile creates the files with appropriate permissions and
> ownerships. There is no code to set the permissions/ownership in spec file.

In %install a package should *never* set ownership of files, as you
should be able to build the package as *any* user (building a package
as root is almost a crime ;-)).  If the Makefile does this, you should
apply a patch in your package to avoid this.

> In RHEL4, rpm was automatically taking the file permissions set on the files
> during the build/compile phase. But in RHEL6, it is changing the ownership
> to root.root.
> My files section is :
> %files
> /var/qmail/bin
> /var/qmail/boot
> %config(noreplace) /var/qmail/control
> /var/qmail/doc
> /var/qmail/log
> /var/qmail/man
> %config(noreplace) /var/qmail/queue
> /var/qmail/users
> /var/qmail/rc
> After searching the net, I tried using %defattr(-,-,-,-) macro at global
> level and the %attr(-,-,-) macro per entry in the %files section. But to no
> avail.

You don't need to use %defattr (defaults to -,root,root), but use %attr
for the files/dirs that need a non-root owner/group, e.g.

%attr(-,qmails,root) /var/qmail/queue/remote
%attr(-,qmailq,root) /var/qmail/queue/remote

Hope this helps,

--    Jos Vos <jos at>
--    X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--    Amsterdam, The Netherlands        |     Fax: +31 20 6948204

More information about the Rpm-list mailing list