* [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs
@ 2011-11-11 17:45 Richard Purdie
2011-11-12 11:14 ` Martin Jansa
0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2011-11-11 17:45 UTC (permalink / raw)
To: openembedded-core
When extracting packages onto the target system in particular, we really
want to ensure the name fields in the tarball are used over and above
the numerical uid/gid values. This patch adds this functionality to opkg
and ensures package upgrades work correctly permission wise
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
new file mode 100644
index 0000000..885f75f
--- a/dev/null
+++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
@@ -0,0 +1,85 @@
+When updating packages on the target device we ideally want to match
+user and group numbers from the existing file system. This patch encourages
+opkg to lookup the uname/gname fields first and only use the hardcoded
+numerical values if that fails.
+
+RP 11/11/11
+
+Index: trunk/libbb/unarchive.c
+===================================================================
+--- trunk.orig/libbb/unarchive.c 2011-11-11 15:52:59.761674091 +0000
++++ trunk/libbb/unarchive.c 2011-11-11 17:04:56.501574419 +0000
+@@ -22,10 +22,13 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
++#include <stdbool.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <utime.h>
+ #include <libgen.h>
++#include <grp.h>
++#include <pwd.h>
+
+ #include "libbb.h"
+
+@@ -436,6 +439,42 @@
+ free(ar_entry);
+ }
+
++static char uname_cache[32] = "";
++static uid_t uid_cache;
++
++static bool update_unamecache(char *uname) {
++ struct passwd *passwd;
++ if (!uname)
++ return FALSE;
++ if (!uname_cache[0] && strcmp(uname_cache, uname) == 0)
++ return TRUE;
++ passwd = getpwnam(uname);
++ if (passwd) {
++ uid_cache = passwd->pw_uid;
++ strncpy(uname, uname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
++static char gname_cache[32] = "";
++static gid_t gid_cache;
++
++static bool update_gnamecache(char *gname) {
++ struct group *group;
++ if (!gname)
++ return FALSE;
++ if (!gname_cache[0] && strcmp(gname_cache, gname) == 0)
++ return TRUE;
++ group = getgrnam(gname);
++ if (group) {
++ gid_cache = group->gr_gid;
++ strncpy(gname, gname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
+
+ static file_header_t *
+ get_header_tar(FILE *tar_stream)
+@@ -515,8 +554,14 @@
+ */
+ tar_entry->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
+
+- tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
+- tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
++ if (update_unamecache(tar.formated.uname))
++ tar_entry->uid = uid_cache;
++ else
++ tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
++ if (update_gnamecache(tar.formated.gname))
++ tar_entry->gid = gid_cache;
++ else
++ tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
+ tar_entry->size = strtol(tar.formated.size, NULL, 8);
+ tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
+
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
index 099a373..8f50f67 10From a781e059562e91c6467be7c4aac43561413b3703 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Fri, 11 Nov 2011 17:17:01 +0000
Subject: opkg: Ensure we use the uname/gname fields when extracting tarballs
---
diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
new file mode 100644
index 0000000..885f75f
--- a/dev/null
+++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
@@ -0,0 +1,85 @@
+When updating packages on the target device we ideally want to match
+user and group numbers from the existing file system. This patch encourages
+opkg to lookup the uname/gname fields first and only use the hardcoded
+numerical values if that fails.
+
+RP 11/11/11
+
+Index: trunk/libbb/unarchive.c
+===================================================================
+--- trunk.orig/libbb/unarchive.c 2011-11-11 15:52:59.761674091 +0000
++++ trunk/libbb/unarchive.c 2011-11-11 17:04:56.501574419 +0000
+@@ -22,10 +22,13 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
++#include <stdbool.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <utime.h>
+ #include <libgen.h>
++#include <grp.h>
++#include <pwd.h>
+
+ #include "libbb.h"
+
+@@ -436,6 +439,42 @@
+ free(ar_entry);
+ }
+
++static char uname_cache[32] = "";
++static uid_t uid_cache;
++
++static bool update_unamecache(char *uname) {
++ struct passwd *passwd;
++ if (!uname)
++ return FALSE;
++ if (!uname_cache[0] && strcmp(uname_cache, uname) == 0)
++ return TRUE;
++ passwd = getpwnam(uname);
++ if (passwd) {
++ uid_cache = passwd->pw_uid;
++ strncpy(uname, uname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
++static char gname_cache[32] = "";
++static gid_t gid_cache;
++
++static bool update_gnamecache(char *gname) {
++ struct group *group;
++ if (!gname)
++ return FALSE;
++ if (!gname_cache[0] && strcmp(gname_cache, gname) == 0)
++ return TRUE;
++ group = getgrnam(gname);
++ if (group) {
++ gid_cache = group->gr_gid;
++ strncpy(gname, gname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
+
+ static file_header_t *
+ get_header_tar(FILE *tar_stream)
+@@ -515,8 +554,14 @@
+ */
+ tar_entry->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
+
+- tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
+- tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
++ if (update_unamecache(tar.formated.uname))
++ tar_entry->uid = uid_cache;
++ else
++ tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
++ if (update_gnamecache(tar.formated.gname))
++ tar_entry->gid = gid_cache;
++ else
++ tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
+ tar_entry->size = strtol(tar.formated.size, NULL, 8);
+ tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
+
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
index 099a373..8f50f67 100644
--- a/meta/recipes-devtools/opkg/opkg_svn.bb
+++ b/meta/recipes-devtools/opkg/opkg_svn.bb
@@ -11,13 +11,14 @@ RREPLACES_${PN} = "opkg-nogpg"
SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
file://add_vercmp.patch \
+ file://add_uname_support.patch \
"
S = "${WORKDIR}/trunk"
SRCREV = "625"
PV = "0.1.8+svnr${SRCPV}"
-PR = "r2"
+PR = "r3"
PACKAGES =+ "libopkg${PKGSUFFIX}-dev libopkg${PKGSUFFIX} update-alternatives-cworth${PKGSUFFIX}"
--
cgit 0.9.0.1
0644
--- a/meta/recipes-devtools/opkg/opkg_svn.bb
+++ b/meta/recipes-devtools/opkg/opkg_svn.bb
@@ -11,13 +11,14 @@ RREPLACES_${PN} = "opkg-nogpg"
SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
file://add_vercmp.patch \
+ file://add_uname_support.patch \
"
S = "${WORKDIR}/trunk"
SRCREV = "625"
PV = "0.1.8+svnr${SRCPV}"
-PR = "r2"
+PR = "r3"
PACKAGES =+ "libopkg${PKGSUFFIX}-dev libopkg${PKGSUFFIX} update-alternatives-cworth${PKGSUFFIX}"
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs
2011-11-11 17:45 [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs Richard Purdie
@ 2011-11-12 11:14 ` Martin Jansa
2011-11-12 11:21 ` Martin Jansa
0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2011-11-12 11:14 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
[-- Attachment #1: Type: text/plain, Size: 2783 bytes --]
On Fri, Nov 11, 2011 at 05:45:28PM +0000, Richard Purdie wrote:
> When extracting packages onto the target system in particular, we really
> want to ensure the name fields in the tarball are used over and above
> the numerical uid/gid values. This patch adds this functionality to opkg
> and ensures package upgrades work correctly permission wise
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
doesn't apply, seems like some parts are twice.. add_uname_support.patch
is somehow added twice and opkg_svn.bb change is there also twice (one
is empty).
OE @ ~/shr-core/openembedded-core $ pw-am.sh.oe-core 14859
2011-11-12 12:09:15
URL:http://patchwork.openembedded.org/patch/14859/mbox/ [7429] ->
"pw-am-14859.patch" [1]
Applying: opkg: Ensure we use the uname/gname fields when extracting
tarballs
fatal: git apply: bad git-diff - expected /dev/null on line 7
Patch failed at 0001 opkg: Ensure we use the uname/gname fields when
extracting tarballs
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
> diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
> new file mode 100644
> index 0000000..885f75f
> --- a/dev/null
> +++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
> @@ -0,0 +1,85 @@
> +When updating packages on the target device we ideally want to match
...
> diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
> index 099a373..8f50f67 10From a781e059562e91c6467be7c4aac43561413b3703 Mon Sep 17 00:00:00 2001
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
> Date: Fri, 11 Nov 2011 17:17:01 +0000
> Subject: opkg: Ensure we use the uname/gname fields when extracting tarballs
>
> ---
> diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
> new file mode 100644
> index 0000000..885f75f
> --- a/dev/null
> +++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
> @@ -0,0 +1,85 @@
> +When updating packages on the target device we ideally want to match
....
> diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
> index 099a373..8f50f67 100644
> --- a/meta/recipes-devtools/opkg/opkg_svn.bb
> +++ b/meta/recipes-devtools/opkg/opkg_svn.bb
> @@ -11,13 +11,14 @@ RREPLACES_${PN} = "opkg-nogpg"
>
> SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
> file://add_vercmp.patch \
...
--
Martin 'JaMa' Jansa jabber: Martin.Jansa@gmail.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs
2011-11-12 11:14 ` Martin Jansa
@ 2011-11-12 11:21 ` Martin Jansa
2011-11-12 12:08 ` Martin Jansa
0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2011-11-12 11:21 UTC (permalink / raw)
To: openembedded-core
From: Richard Purdie <richard.purdie@linuxfoundation.org>
When extracting packages onto the target system in particular, we really
want to ensure the name fields in the tarball are used over and above
the numerical uid/gid values. This patch adds this functionality to opkg
and ensures package upgrades work correctly permission wise
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
.../opkg/opkg/add_uname_support.patch | 85 ++++++++++++++++++++
meta/recipes-devtools/opkg/opkg_svn.bb | 3 +-
2 files changed, 87 insertions(+), 1 deletions(-)
create mode 100644 meta/recipes-devtools/opkg/opkg/add_uname_support.patch
diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
new file mode 100644
index 0000000..885f75f
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch
@@ -0,0 +1,85 @@
+When updating packages on the target device we ideally want to match
+user and group numbers from the existing file system. This patch encourages
+opkg to lookup the uname/gname fields first and only use the hardcoded
+numerical values if that fails.
+
+RP 11/11/11
+
+Index: trunk/libbb/unarchive.c
+===================================================================
+--- trunk.orig/libbb/unarchive.c 2011-11-11 15:52:59.761674091 +0000
++++ trunk/libbb/unarchive.c 2011-11-11 17:04:56.501574419 +0000
+@@ -22,10 +22,13 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
++#include <stdbool.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <utime.h>
+ #include <libgen.h>
++#include <grp.h>
++#include <pwd.h>
+
+ #include "libbb.h"
+
+@@ -436,6 +439,42 @@
+ free(ar_entry);
+ }
+
++static char uname_cache[32] = "";
++static uid_t uid_cache;
++
++static bool update_unamecache(char *uname) {
++ struct passwd *passwd;
++ if (!uname)
++ return FALSE;
++ if (!uname_cache[0] && strcmp(uname_cache, uname) == 0)
++ return TRUE;
++ passwd = getpwnam(uname);
++ if (passwd) {
++ uid_cache = passwd->pw_uid;
++ strncpy(uname, uname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
++static char gname_cache[32] = "";
++static gid_t gid_cache;
++
++static bool update_gnamecache(char *gname) {
++ struct group *group;
++ if (!gname)
++ return FALSE;
++ if (!gname_cache[0] && strcmp(gname_cache, gname) == 0)
++ return TRUE;
++ group = getgrnam(gname);
++ if (group) {
++ gid_cache = group->gr_gid;
++ strncpy(gname, gname_cache, 32);
++ return TRUE;
++ }
++ return FALSE;
++}
++
+
+ static file_header_t *
+ get_header_tar(FILE *tar_stream)
+@@ -515,8 +554,14 @@
+ */
+ tar_entry->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
+
+- tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
+- tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
++ if (update_unamecache(tar.formated.uname))
++ tar_entry->uid = uid_cache;
++ else
++ tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
++ if (update_gnamecache(tar.formated.gname))
++ tar_entry->gid = gid_cache;
++ else
++ tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
+ tar_entry->size = strtol(tar.formated.size, NULL, 8);
+ tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
+
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
index 099a373..8f50f67 100644
--- a/meta/recipes-devtools/opkg/opkg_svn.bb
+++ b/meta/recipes-devtools/opkg/opkg_svn.bb
@@ -11,13 +11,14 @@ RREPLACES_${PN} = "opkg-nogpg"
SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
file://add_vercmp.patch \
+ file://add_uname_support.patch \
"
S = "${WORKDIR}/trunk"
SRCREV = "625"
PV = "0.1.8+svnr${SRCPV}"
-PR = "r2"
+PR = "r3"
PACKAGES =+ "libopkg${PKGSUFFIX}-dev libopkg${PKGSUFFIX} update-alternatives-cworth${PKGSUFFIX}"
--
1.7.8.rc1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs
2011-11-12 11:21 ` Martin Jansa
@ 2011-11-12 12:08 ` Martin Jansa
0 siblings, 0 replies; 4+ messages in thread
From: Martin Jansa @ 2011-11-12 12:08 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 4067 bytes --]
On Sat, Nov 12, 2011 at 12:21:34PM +0100, Martin Jansa wrote:
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
Seems to work fine, thanks a lot!
Acked-by: Martin Jansa <Martin.Jansa@gmail.com>
SHR root@gjama / $ opkg remove -force-depends -force-remove dbus-1
Removing package dbus-1 from root...
Stopping system message bus: Removing any system startup links for dbus-1 ...
/etc/rc0.d/K20dbus-1
/etc/rc1.d/K20dbus-1
/etc/rc2.d/S02dbus-1
/etc/rc3.d/S02dbus-1
/etc/rc5.d/S02dbus-1
/etc/rc6.d/K20dbus-1
Collected errors:
* pkg_run_script: package "dbus-1" prerm script returned status 1.
SHR root@gjama / $ grep message /etc/passwd
messagebus:x:42:101:Linux User,,,:/var/run/dbus:/bin/sh
SHR root@gjama / $ grep message /etc/group
messagebus:x:101:
SHR root@gjama / $ opkg install dbus-1
Installing dbus-1 (1.4.12-r7) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/dbus-1_1.4.12-r7_armv4t.ipk.
Running groupadd commands...
Note: group netdev already exists, not re-creating it
Running useradd commands...
Note: username messagebus already exists, not re-creating it
Configuring dbus-1.
Adding system startup for /etc/init.d/dbus-1.
SHR root@gjama / $ ll /usr/libexec/dbus-daemon-launch-helper
-rwsr-xr-- 1 root 998 142748 Nov 12 12:26 /usr/libexec/dbus-daemon-launch-helper
SHR root@gjama / $ opkg remove -force-depends -force-remove dbus-1
Removing package dbus-1 from root...
Stopping system message bus: Removing any system startup links for dbus-1 ...
/etc/rc0.d/K20dbus-1
/etc/rc1.d/K20dbus-1
/etc/rc2.d/S02dbus-1
/etc/rc3.d/S02dbus-1
/etc/rc5.d/S02dbus-1
/etc/rc6.d/K20dbus-1
Collected errors:
* pkg_run_script: package "dbus-1" prerm script returned status 1.
SHR root@gjama / $ opkg update; opkg upgrade opkg; opkg install dbus-1
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//all/Packages.gz.
Inflating http://jama.dyndns-home.com/org.openembedded.shr-core//all/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/jama-all.
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/Packages.gz.
Inflating http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/jama-armv4t.
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//om_gta02/Packages.gz.
Inflating http://jama.dyndns-home.com/org.openembedded.shr-core//om_gta02/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/jama-om_gta02.
Installing opkg (1:0.1.8+svnr625-r3) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/opkg_0.1.8+svnr625-r3_armv4t.ipk.
Installing opkg-config-base (1.0-r0) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//om_gta02/opkg-config-base_1.0-r0_om_gta02.ipk.
Installing update-alternatives-cworth (1:0.1.8+svnr625-r3) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//all/update-alternatives-cworth_0.1.8+svnr625-r3_all.ipk.
Installing libopkg1 (1:0.1.8+svnr625-r3) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/libopkg1_0.1.8+svnr625-r3_armv4t.ipk.
Configuring opkg-config-base.
Configuring update-alternatives-cworth.
Configuring libopkg1.
Configuring opkg.
update-alternatives: Linking //usr/bin/opkg to /usr/bin/opkg-cl
Installing dbus-1 (1.4.12-r7) to root...
Downloading http://jama.dyndns-home.com/org.openembedded.shr-core//armv4t/dbus-1_1.4.12-r7_armv4t.ipk.
Running groupadd commands...
Note: group netdev already exists, not re-creating it
Running useradd commands...
Note: username messagebus already exists, not re-creating it
Configuring dbus-1.
Adding system startup for /etc/init.d/dbus-1.
SHR root@gjama / $ ll /usr/libexec/dbus-daemon-launch-helper
-rwsr-xr-- 1 root messagebus 142748 Nov 12 12:26 /usr/libexec/dbus-daemon-launch-helper
--
Martin 'JaMa' Jansa jabber: Martin.Jansa@gmail.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-12 12:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-11 17:45 [PATCH] opkg: Ensure we use the uname/gname fields when extracting tarballs Richard Purdie
2011-11-12 11:14 ` Martin Jansa
2011-11-12 11:21 ` Martin Jansa
2011-11-12 12:08 ` Martin Jansa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox