Библиотека сайта или "Мой Linux Documentation Project"
|Maximum RPM: Taking the Red Hat Package Manager to the Limit|
|Prev||Chapter 16. Making a Package That Can Build Anywhere||Next|
In cases where the package builder cannot create the files to be packaged with the proper ownership and permissions, the %attr macro can be used to make things right.
The %attr macro has the following format:
<mode>is represented in traditional numeric fashion.
<user>is specified by the login name of the user. Numeric UIDs are not used, for reasons we'll explore in a moment.
<group>is specified by the group's name, as entered in
/etc/group. Numeric GIDs are not used, either. Yes, we'll be discussing that, too!
<file>represents the file. Shell-style globbing is supported.
This works for user and group specifications, as well.
The other wrinkle is that, although we've been showing the three file attributes separated by commas, in reality they could be separated by spaces as well. Whichever delimiter you choose, it pays to be consistent throughout a spec file.
cdplayerwith a liberal sprinkling of %attrs. Here's what the %files list looks like after we've had our way with it:
A couple points are worth noting here. The line for
README shows that multiple macros can be used on
a line — in this case, one to set file attributes, and one to
mark the file as being documentation. The %attr
/usr/local/bin/cdp declares the file to be
setuid root. If it sends a shiver down your spine to know that
anybody can create a package that will run setuid root when installed
on your system — Good! Just because RPM makes it easy to
install software doesn't mean that you should blindly install every
package you find.
What's this about group "rot"? Looking back at the rpm
-qlvp output, it looks like
/usr/local/man/man1/cdp.1 has a bogus group.
Looking back even further, it's there in the %attr
for that file. Must have been a typo. We could pretend that RPM used
advanced artificial intelligence technology to come to the same
conclusion as we did and made the appropriate change, but in reality,
RPM simply used the only group identifier it could count on —
root. RPM will do the same thing if it can't resolve a user
RPM did just what it was supposed to — It gave the files the attributes specified by the %attr macros.
At the start of this section, we mentioned that the %attr macro wouldn't accept numeric uids or gids, and we promised to explain why. The reason is simply that, even if a package requires a certain user or group to own the package's files, the user may not have the same uid/gid from system to system. There — wasn't that simple?
In the next chapter, we'll discuss how to make your packaged software safe against modification by unscrupulous people. The name of the game is Pretty Good Privacy, and you'll see how signing packages with PGP is easier than you think!
Только зарегистрированные пользователи могут оценивать и комментировать статьи.