]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/gnupg/files/15_free_caps.dpatch
gnupg: add 1.4.5-1 from Debian.
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / gnupg / files / 15_free_caps.dpatch
1 #! /bin/sh -e
2 ## 15_free_caps.dpatch by  <mpitt@debian.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: cap_from_text() allocates a new capability context, which is not freed
6 ## DP: in the original sources. This patch fixes this.
7 ## DP: Please note that this approach alone is not safe: when using
8 ## DP: USE_CAPABILITIES the root user is not setuid() back any more to a normal
9 ## DP: user.
10
11 if [ $# -lt 1 ]; then
12     echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
13     exit 1
14 fi
15
16 [ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
17 patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
18
19 case "$1" in
20     -patch) patch -p1 ${patch_opts} < $0;;
21     -unpatch) patch -R -p1 ${patch_opts} < $0;;
22     *)
23         echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
24         exit 1;;
25 esac
26
27 exit 0
28
29 @DPATCH@
30 diff -urNad /home/weasel/tmp/debian-gpg/gnupg-1.2.5/g10/status.c gnupg-1.2.5/g10/status.c
31 --- /home/weasel/tmp/debian-gpg/gnupg-1.2.5/g10/status.c        2004-07-21 09:59:45.000000000 +0200
32 +++ gnupg-1.2.5/g10/status.c    2004-08-01 20:07:42.071690680 +0200
33 @@ -346,6 +346,9 @@
34  {
35      char buf[100];
36      struct shmid_ds shmds;
37 +#ifdef USE_CAPABILITIES
38 +    cap_t caps;
39 +#endif
40  
41  #ifndef IPC_RMID_DEFERRED_RELEASE
42      atexit( remove_shmid );
43 @@ -371,7 +374,9 @@
44                             (unsigned)shm_size/1024, shm_area, shm_id );
45      if( lock_mem ) {
46  #ifdef USE_CAPABILITIES
47 -       cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
48 +       caps = cap_from_text("cap_ipc_lock=ep");
49 +       cap_set_proc( caps );
50 +       cap_free( caps );
51  #endif
52         /* (need the cast for Solaris with Sun's workshop compilers) */
53         if ( mlock ( (char*)shm_area, shm_size) )
54 @@ -380,7 +385,9 @@
55         else
56             shm_is_locked = 1;
57  #ifdef USE_CAPABILITIES
58 -       cap_set_proc( cap_from_text("cap_ipc_lock+p") );
59 +       caps = cap_from_text("cap_ipc_lock=p");
60 +       cap_set_proc( caps );
61 +       cap_free( caps );
62  #endif
63      }
64  
65 @@ -407,7 +414,9 @@
66  
67      if( lock_mem ) {
68  #ifdef USE_CAPABILITIES
69 -       cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
70 +       caps = cap_from_text("cap_ipc_lock=ep");
71 +       cap_set_proc( caps );
72 +       cap_free( caps );
73  #endif
74  #ifdef IPC_HAVE_SHM_LOCK
75         if ( shmctl (shm_id, SHM_LOCK, 0) )
76 @@ -419,7 +428,9 @@
77         log_info("Locking shared memory %d failed: No way to do it\n", shm_id );
78  #endif
79  #ifdef USE_CAPABILITIES
80 -       cap_set_proc( cap_from_text("cap_ipc_lock+p") );
81 +       caps = cap_from_text("cap_ipc_lock=p");
82 +       cap_set_proc( caps );
83 +       cap_free( caps );
84  #endif
85      }
86  
87 diff -urNad /home/weasel/tmp/debian-gpg/gnupg-1.2.5/util/secmem.c gnupg-1.2.5/util/secmem.c
88 --- /home/weasel/tmp/debian-gpg/gnupg-1.2.5/util/secmem.c       2004-02-24 17:06:58.000000000 +0100
89 +++ gnupg-1.2.5/util/secmem.c   2004-08-01 20:08:10.873412378 +0200
90 @@ -97,12 +97,18 @@
91  {
92  #if defined(USE_CAPABILITIES) && defined(HAVE_MLOCK)
93      int err;
94 +    cap_t caps;
95 +
96 +    caps = cap_from_text("cap_ipc_lock=ep");
97 +    cap_set_proc( caps );
98 +    cap_free( caps );
99  
100 -    cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
101      err = mlock( p, n );
102      if( err && errno )
103         err = errno;
104 -    cap_set_proc( cap_from_text("cap_ipc_lock+p") );
105 +    caps = cap_from_text("cap_ipc_lock=p");
106 +    cap_set_proc( caps );
107 +    cap_free( caps );
108  
109      if( err ) {
110         if( errno != EPERM
111 @@ -301,8 +307,12 @@
112      if( !n ) {
113  #ifndef __riscos__
114  #ifdef USE_CAPABILITIES
115 +       cap_t caps;
116 +
117         /* drop all capabilities */
118 -       cap_set_proc( cap_from_text("all-eip") );
119 +       caps = cap_from_text("all-eip");
120 +       cap_set_proc( caps );
121 +       cap_free( caps );
122  
123  #elif !defined(HAVE_DOSISH_SYSTEM)
124         uid_t uid;