------------------------------------------------------------
revno: 677
revision-id:[EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: s3-ctdb-tridge
timestamp: Fri 2007-11-23 13:56:11 +1100
message:
  - don't use the generic dmapi.c service in tsmsm. I get intermittent
    -1/EINVAL from using the session in that module. I suspect the
    problem is the use of capabilities, but for now this is the simplest
    fix. We the tsmsm module is now standalone, and much closer to the
    command line isoffline.c code.
modified:
  source/modules/vfs_tsmsm.c     vfs_tsmsm.c-20070827024912-m3pirz28sej5g6pz-1
=== modified file 'source/modules/vfs_tsmsm.c'
--- a/source/modules/vfs_tsmsm.c        2007-11-23 01:58:52 +0000
+++ b/source/modules/vfs_tsmsm.c        2007-11-23 02:56:11 +0000
@@ -65,8 +65,9 @@
 #define DM_ATTRIB_OBJECT "IBMObj"
 #define DM_ATTRIB_MIGRATED "IBMMig"
 
+static dm_sessid_t tsmsm_sid = DM_NO_SESSION;
+
 struct tsmsm_struct {
-       dm_sessid_t sid;
        float online_ratio;
        char *hsmscript;
 };
@@ -87,14 +88,24 @@
        const char *hsmscript, *tsmname;
        const char *fres;
        
-       if(!tsmd) {
+       if (!tsmd) {
                DEBUG(0,("tsmsm_connect: out of memory!\n"));
                return -1;
        }
 
-       tsmd->sid = *(dm_sessid_t*) dmapi_get_current_session();
+       /* create a new session if needed */
+       if (tsmsm_sid == DM_NO_SESSION) {
+               become_root();
+               if (dm_create_session(DM_NO_SESSION, "samba_tsmsm", &tsmsm_sid) 
!= 0) {
+                       DEBUG(0,("tsmsm_connect: failed to create dmapi session 
for samba_tsmsm: %s\n",
+                                strerror(errno)));
+                       unbecome_root();
+                       return -1;
+               }
+               unbecome_root();
+       }
 
-       if(tsmd->sid == DM_NO_SESSION) {
+       if (tsmsm_sid == DM_NO_SESSION) {
                DEBUG(0,("tsmsm_connect: no DMAPI session for Samba is 
available!\n"));
                TALLOC_FREE(tsmd);
                return -1;
@@ -172,7 +183,7 @@
        memset(&dmname, 0, sizeof(dmname));
        strlcpy((char *)&dmname.an_chars[0], DM_ATTRIB_OBJECT, 
sizeof(dmname.an_chars));
 
-       ret = dm_get_dmattr(tsmd->sid, dmhandle, dmhandle_len, 
+       ret = dm_get_dmattr(tsmsm_sid, dmhandle, dmhandle_len, 
                            DM_NO_TOKEN, &dmname, 0, NULL, &rlen);
 
        /* its offline if the IBMObj attribute exists */

Reply via email to