[OpenAFS-devel] Patch for NT server manager admin utility

Dave Bailey D.Bailey@bristol.ac.uk
Thu, 28 Mar 2002 14:21:35 -0000


Hi,

Included below is a small patch for the AFS Server Manager for NT. It adds
one command line option to the utility that takes the current AFS
credentials and uses them by default, bypassing the initial authentication
dialog box. It's useful if you're not running kaserver (i.e. if you've moved
over to kerberos 5) and can't authenticate again by the normal AFS means.

Patch is against openafs-1.2.3. The new switch is /useexisting.

Cheers,
    Dave

*** src/WINNT/afssvrmgr/cmdline.cpp	Sat Nov  4 10:02:02 2000
--- /h/openafs-1.2.3/src/WINNT/afssvrmgr/cmdline.cpp	Thu Mar 28 13:59:06
2002
***************
*** 12,17 ****
--- 12,19 ----
  #include <afs/stds.h>
  }
  
+ #include "../afsapplib/afsapplib.h"
+ 
  #include "svrmgr.h"
  #include "cmdline.h"
  #include "action.h"
***************
*** 32,37 ****
--- 34,40 ----
     swUSER,
     swPASSWORD,
     swLOOKUP,
+    swUSEEXISTING
  } SWITCH;
  
  static struct {
***************
*** 40,53 ****
     BOOL fPresent;
     TCHAR szValue[ cchRESOURCE ];
  } aSWITCHES[] = {
!    { TEXT("cell"),      TRUE  },
!    { TEXT("subset"),    TRUE  },
!    { TEXT("server"),    TRUE  },
!    { TEXT("reset"),     FALSE },
!    { TEXT("confirm"),   FALSE },
!    { TEXT("user"),      TRUE  },
!    { TEXT("password"),  TRUE  },
!    { TEXT("lookup"),    FALSE }
  };
  
  #define nSWITCHES (sizeof(aSWITCHES) / sizeof(aSWITCHES[0]))
--- 43,57 ----
     BOOL fPresent;
     TCHAR szValue[ cchRESOURCE ];
  } aSWITCHES[] = {
!    { TEXT("cell"),        TRUE  },
!    { TEXT("subset"),      TRUE  },
!    { TEXT("server"),      TRUE  },
!    { TEXT("reset"),       FALSE },
!    { TEXT("confirm"),     FALSE },
!    { TEXT("user"),        TRUE  },
!    { TEXT("password"),    TRUE  },
!    { TEXT("lookup"),      FALSE },
!    { TEXT("useexisting"), FALSE }
  };
  
  #define nSWITCHES (sizeof(aSWITCHES) / sizeof(aSWITCHES[0]))
***************
*** 250,255 ****
--- 254,289 ----
        {
        return opLOOKUPERRORCODE;
        }
+ 
+    if (aSWITCHES[ swUSEEXISTING ].fPresent)
+      {
+        ULONG ulStatus;
+        TCHAR szDefCell[ cchNAME ];
+        
+        if (aSWITCHES[ swCELL ].fPresent)
+ 	 {
+ 	   lstrcpy(szDefCell,aSWITCHES[ swCELL ].szValue);
+ 	 }
+        else
+ 	 {
+ 	   AfsAppLib_GetLocalCell(szDefCell);
+ 	 }
+        g.hCreds = AfsAppLib_GetCredentials(szDefCell,&ulStatus);
+        if (g.hCreds != NULL)
+ 	 {
+ 	   LPOPENCELL_PACKET lpocp = New (OPENCELL_PACKET);
+ 
+ 	   memset(lpocp,0x00,sizeof(OPENCELL_PACKET));
+ 	   lstrcpy(lpocp->szCell,szDefCell);
+ 	   lpocp->fCloseAppOnFail = TRUE;
+ 	   lpocp->hCreds = g.hCreds;
+ 	   lpocp->sub = NULL;
+ 	   StartTask(taskOPENCELL,NULL,lpocp);
+ 	   return opNOCELLDIALOG;
+ 	 }
+        else
+ 	 return opCLOSEAPP;
+      }
  
     if (aSWITCHES[ swCELL ].fPresent)
        {



                                              __  _
David Bailey                              .-.'  `; `-._  __  _
Bristol University                       (_,         .-:'  `; `-._
Email: D.Bailey@Bristol.ac.uk          ,'o"(        (_,           )
Tel:   +44 117 9546879                (__,-'      ,'o"(            )>
Fax:   +44 117 9255624                   (       (__,-'            )
                                          `-'._.--._(             )
                                             |||  |||`-'._.--._.-'
                                                        |||  |||