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)));
James Peach
2006-Oct-30 06:28 UTC
[Samba] dmapi doesn't work on aix; possible fix included
On 29/10/06, J Raynor <raynorj@mn.rr.com> wrote:> 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?This code was originally written for Linux and IRIX. IIRC in Linux there was a problem where the process capabilities were reset across fork() because Samba changes its effective user ID. So when we get a permission error we go back and try to re-acquire our capabilities.> 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 isNote that DMAPI_ACCESS_CAPABILITY is not a real capability, it's just a name for whatever capability set is needed to do DMAPI operations on the current platform.> supposed to allow the functions to work, but to my knowledge AIX doesn't > have posix capabilties.This is well beyond my knowledge of AIX. I used capabilities for this, rather than (un)become_root for performance reasons. If there's no other way to achieve the functionality, then I guess this is fine. I'd prefer a feature-based test for whether this is necessary, rather than a platform- based test. Something like #if !defined(HAVE_POSIX_CAPABILITIES) become_root(); #endif> 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))); > > > > > -- > To unsubscribe from this list go to the following URL and read the > instructions: https://lists.samba.org/mailman/listinfo/samba >-- James Peach | jorgar@gmail.com