Bug 10091

Summary: opkg-build check for UID >99 is overly broad, resulting warning has poor signal-to-noise ratio
Product: [Yocto Project Subprojects] opkg Reporter: Will Page <will.page>
Component: opkgAssignee: Alejandro del Castillo <alejandro.delcastillo>
Status: RESOLVED NOTABUG QA Contact:
Severity: enhancement    
Priority: Undecided    
Version: unspecified   
Target Milestone: 0.3.4   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Will Page 2016-08-04 22:39:46 UTC
opkg-build has a check for files being packaged that are not owned by system accounts:

	large_uid_files=`find . -uid +99 || true`

	if [ "$ogargs" = "" ]  && [ -n "$large_uid_files" ]; then
		echo "*** Warning: The following files have a UID greater than 99.
You probably want to chown these to a system user: " >&2
		ls -ld $large_uid_files
		echo >&2
	fi
	    
This check is unnecessarily broad, and warns in cases of files owned by user accounts that would be created during installation.

The most common failure mode, that it seems this is meant to check for, is when a non-root user is building a package, and the files were copied as that user, and thus are owned by that user.

Ideally this warning would be changed to check if the files are owned by a non-root user that has the same UID as the building user's EUID, and warn in that case.

Roughly:
# if a file has non-root permissions, and is owned by the user account
# that's being used to build, that's probably a mistake
if [ $EUID -ne 0 ]; then
  user_uid_files=`find . -uid $EUID || true`
  if [ -n "$user_uid_files" ]; then
    echo "*** Warning: The following files have the same UID as the current user.
You probably want to chown these to a system user: " >&2
    ls -ld $large_uid_files
    echo >&2
  fi
fi
Comment 1 Alejandro del Castillo 2016-11-18 23:43:30 UTC
I believe opkg-build is trying to follow suit with debian. The debian package linter has a check to make sure that the UID is set to one of the globally statically allocated UIDs, which sounds sane to me:

https://lintian.debian.org/tags/wrong-file-owner-uid-or-gid.html

For the use case you are referring to (accounts created by maintainer scripts), the policy says:

"It's possible for a Policy-compliant package to trigger this tag if the user is created in the preinst maintainer script, but this is a very rare case and doesn't appear to be necessary. If you found yourself needing to create a package that works this way, please file a bug against Lintian to let the maintainers know"
Comment 2 Alejandro del Castillo 2016-12-02 15:35:14 UTC
Opkg is following Debian policy