The makefile for the lsm module, and a test app I used to verify that
getxattr() works properly with my lsm.
---
Makefile | 10 ++++++++++
xattr_helper.cpp | 54
++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+)
diff -uprN null/Makefile fireflier_lsm/Makefile
--- null/Makefile 1970-01-01 02:00:00.000000000 +0200
+++ fireflier_lsm/Makefile 2006-04-07 15:08:00.000000000 +0300
@@ -0,0 +1,10 @@
+obj-m += fireflier.o
+fireflier-objs := hooks.o autolabel.o sidtab.o fireflier_debug.o
+KERN = $(shell uname -r)
+#KERN = 2.6.16.1
+all:
+ make -C /lib/modules/$(KERN)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(KERN)/build M=$(PWD) clean
+
diff -uprN null/xattr_helper.cpp fireflier_lsm/xattr_helper.cpp
--- null/xattr_helper.cpp 1970-01-01 02:00:00.000000000 +0200
+++ fireflier_lsm/xattr_helper.cpp 2006-04-07 18:06:38.000000000 +0300
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <attr/xattr.h>
+
+void die(const char* msg)
+{
+
+ perror(msg);
+ exit(1);
+}
+
+void showArray(const char* array,ssize_t len)
+{
+ for(int i=0;i<len;i++)
+ if(array[i])
+ putchar(array[i]);
+ else putchar('\n');
+}
+
+int main(int argc,char* argv[])
+{
+
+ if(argc==2)
+ {
+ const char* filename = argv[1];
+ ssize_t len = listxattr(filename,NULL,0);
+ if(len==-1)
+ die("error getting list size");
+ char* list = new char[len+1];
+ if((len=listxattr(filename,list,len))==-1)
+ die("error listing attributes names");
+ printf("List of security attributes:\n");
+ showArray(list,len);
+ delete[] list;
+ }
+ else if(argc==3)
+ {
+ const char* filename = argv[1];
+ const char* name = argv[2];
+ ssize_t len = getxattr(filename,name,NULL,0);
+ if(len==-1)
+ die("error getting xattr list size");
+ char* list = new char[len+1];
+ if((len = getxattr(filename,name,list,len))==-1)
+ die("error getting xattr");
+ printf("xattr %s of %s is:",name,filename);
+ showArray(list,len);
+ delete[] list;
+ }
+ else
+ printf("Usage: %s filename [xattr_name]\n",argv[0]);
+ return 0;
+}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]