xattrs support

2014-09-12 Thread Dmitry Falko

Hello!

I have a question on support xattrs in dpkg-dep. As far as I know in 
version 1.27.1 (Ubuntu 14.04) supports the creation of tar archives 
preserving extended attributes, perhaps it makes sense to add ability to 
create packages containing files with extended attributes. May be 
special options?


--

Best regards, Dmitry!




Re: xattrs support

2014-09-12 Thread Dmitry Falko

xattrs support for files in deb packages.

dpkg-dep use special option of tar to preserve extended attributes, i 
made it switched on by default and have arg to swithc off, but maybe 
it's not rigth.




---
 dpkg-deb/build.c|7 ++-
 dpkg-deb/dpkg-deb.h |3 +++
 dpkg-deb/extract.c  |5 +
 dpkg-deb/main.c |3 +++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 0b9cfb6..097f22a 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -599,8 +599,13 @@ do_build(const char *const *argv)
 m_dup2(p2[1],1); close(p2[0]); close(p2[1]);
 if (chdir(dir))
   ohshite(_("failed to chdir to `%.255s'"), dir);
-execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", 
"--no-unquote",

+if(!xattrflag) {
+  execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", 
"--no-unquote",

+   "-T", "-", "--no-recursion", "--xattrs", NULL);
+} else {
+  execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", 
"--no-unquote",

"-T", "-", "--no-recursion", NULL);
+}
 ohshite(_("unable to execute %s (%s)"), "tar -cf", TAR);
   }
   close(p1[0]);
diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index 2233c96..00c5b06 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -38,6 +38,7 @@ action_func do_fsystarfile;
 extern int opt_verbose;
 extern int opt_uniform_compression;
 extern int debugflag, nocheckflag;
+extern int xattrflag;

 extern struct deb_version deb_format;

@@ -52,6 +53,8 @@ enum dpkg_tar_options {
 DPKG_TAR_PERMS = DPKG_BIT(2),
 /** Do not set tar mtime on extract. */
 DPKG_TAR_NOMTIME = DPKG_BIT(3),
+/** Do not preserve xattrs on extract */
+DPKG_TAR_NOXATTRS = DPKG_BIT(4),
 };

 void extracthalf(const char *debar, const char *dir,
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 5a076b7..d96c5f0 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -124,6 +124,9 @@ extracthalf(const char *debar, const char *dir,
   bool header_done;
   enum compressor_type decompressor = COMPRESSOR_TYPE_GZIP;

+  if(xattrflag)
+taroption |= DPKG_TAR_NOXATTRS;
+
   arfd = open(debar, O_RDONLY);
   if (arfd < 0)
 ohshite(_("failed to read archive `%.255s'"), debar);
@@ -331,6 +334,8 @@ extracthalf(const char *debar, const char *dir,
 command_add_arg(&cmd, "-p");
   if (taroption & DPKG_TAR_NOMTIME)
 command_add_arg(&cmd, "-m");
+  if(!(taroption & DPKG_TAR_NOXATTRS))
+command_add_arg(&cmd, "--xattrs");

   command_add_arg(&cmd, "-f");
   command_add_arg(&cmd, "-");
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index 7c9d8e8..0a949e5 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -114,6 +114,7 @@ usage(const struct cmdinfo *cip, const char *value)
 "  -S Set the compression strategy when 
building.\n"
 " Allowed values: none; extreme 
(xz);\n"
 " filtered, huffman, rle, fixed 
(gzip).\n"
+"  --no-xattrs  Do not preserve file extended 
attributes\n"

 "\n"));

   printf(_(
@@ -144,6 +145,7 @@ int debugflag = 0;
 int nocheckflag = 0;
 int opt_verbose = 0;
 int opt_uniform_compression = 0;
+int xattrflag = 0;

 struct deb_version deb_format = DEB_VERSION(2, 0);

@@ -241,6 +243,7 @@ static const struct cmdinfo cmdinfos[]= {
   { NULL,'z', 1, NULL,   NULL, set_compress_level },
   { NULL,'Z', 1, NULL,   NULL, set_compress_type  },
   { NULL,'S', 1, NULL,   NULL, 
set_compress_strategy },

+  { "no-xattrs",  0,  0, &xattrflag, NULL, NULL,  1 },
   { "showformat",0,   1, NULL,   &showformat, 
NULL },

   { "help",  '?', 0, NULL,   NULL, usage},
   { "version",   0,   0, NULL,   NULL, printversion },
--
1.7.9.5

--
Best Regards, Dmitry!


--
To UNSUBSCRIBE, email to debian-dpkg-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/5412e380.2060...@digiflak.com



Re: xattrs support

2014-09-12 Thread Mimi Zohar
On Fri, 2014-09-12 at 12:12 +0400, Dmitry Falko wrote: 
> Hello!
> 
> I have a question on support xattrs in dpkg-dep. As far as I know in 
> version 1.27.1 (Ubuntu 14.04) supports the creation of tar archives 
> preserving extended attributes, perhaps it makes sense to add ability to 
> create packages containing files with extended attributes. May be 
> special options?

I'm very interested in having xattrs included in deb packages.  Which
xattrs in particular are you interested in?  Part of the problem is that
fake-root creates the directory structure, but wouldn't be able to copy
the security xattrs. Reading security xattrs is permitted, but writing
security xattrs requires privilege.

Mimi



-- 
To UNSUBSCRIBE, email to debian-dpkg-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/1410543843.5187.209.ca...@dhcp-9-2-203-236.watson.ibm.com