[Samba] dmapi doesn't work on aix; possible fix included

J Raynor raynorj at mn.rr.com
Sun Oct 29 16:37:24 GMT 2006


I'm running samba 3.0.23c on aix 5.3 TL4.  I'm using Tivoli HSM 5.3.4.0 
on a JFS2 filesystem.  Samba compiled fine, and I set "dmapi support = 
yes" in smb.conf, but samba wouldn't recognize offline files ("migrated 
files" in tsm terminology).  After setting a higher log level I think 
I've tracked down the problem.  The patch is at the bottom of this email.

The first problem is this snippet in dmapi_file_flags() in smbd/dmapi.c:

         err = dm_path_to_handle(CONST_DISCARD(char *, path),
                 &dm_handle, &dm_handle_len);
         if (err < 0) {
                 DEBUG(DMAPI_TRACE, ("dm_path_to_handle(%s): %s\n",
                             path, strerror(errno)));

                 if (errno != EPERM) {
                         return 0;
                 }



On AIX, dm_path_to_handle() is returning EACCES instead of EPERM, so it 
hits the return 0.  Is EPERM supposed to be the only allowed error, or 
is this something that's likely implementation dependent?

Changing the if-condition to (errno != EPERM && errno != EACCES) lets 
things continue on.  The rest of the problem in dmapi_file_flags() is 
that things are running with the effective uid of the user, so dmapi 
calls are failing.  The posix capability DMAPI_ACCESS_CAPABILITY is 
supposed to allow the functions to work, but to my knowledge AIX doesn't 
  have posix capabilties.

I used become_root/unbecome_root around the dmapi calls, and this 
appeared to get things to work.  Samba's log messages are indicating 
that files are offline, and Windows Explorer is picking up on this and 
changing the file icons to indicate that the files are offline. However, 
I don't know if my solution is entirely correct.  Here's the patch:




*** dmapi.c.orig        Sat Oct 28 02:33:13 2006
--- dmapi.c     Sat Oct 28 11:12:54 2006
***************
*** 246,252 ****
                 DEBUG(DMAPI_TRACE, ("dm_path_to_handle(%s): %s\n",
                             path, strerror(errno)));

!               if (errno != EPERM) {
                         return 0;
                 }

--- 246,252 ----
                 DEBUG(DMAPI_TRACE, ("dm_path_to_handle(%s): %s\n",
                             path, strerror(errno)));

!               if (errno != EPERM && errno != EACCES) {
                         return 0;
                 }

***************
*** 259,266 ****
--- 259,274 ----

                 set_effective_capability(DMAPI_ACCESS_CAPABILITY);

+ #ifdef AIX
+               become_root();
+ #endif
+
                 err = dm_path_to_handle(CONST_DISCARD(char *, path),
                         &dm_handle, &dm_handle_len);
+
+ #ifdef AIX
+               unbecome_root();
+ #endif
                 if (err < 0) {
                         DEBUG(DMAPI_TRACE,
                             ("retrying dm_path_to_handle(%s): %s\n",
***************
*** 269,276 ****
--- 277,293 ----
                 }
         }

+ #ifdef AIX
+       become_root();
+ #endif
+
         err = dm_get_eventlist(dmapi_session, dm_handle, dm_handle_len,
                 DM_NO_TOKEN, DM_EVENT_MAX, &events, &nevents);
+
+ #ifdef AIX
+       unbecome_root();
+ #endif
+
         if (err < 0) {
                 DEBUG(DMAPI_TRACE, ("dm_get_eventlist(%s): %s\n",
                             path, strerror(errno)));





More information about the samba mailing list