]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
winnt-servermgr-use-existing-creds-option-20020401
authorDavid Bailey <D.Bailey@bristol.ac.uk>
Mon, 1 Apr 2002 17:25:37 +0000 (17:25 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 1 Apr 2002 17:25:37 +0000 (17:25 +0000)
This adds /useexisting to use current AFS creds, 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.

src/WINNT/afssvrmgr/cmdline.cpp

index 28bc8cb7a06f9dd48dcec9dbf0547361cc2ba2da..2293027682bf041ac62f7520dcbfa15a8892a6c4 100644 (file)
@@ -12,6 +12,8 @@ extern "C" {
 #include <afs/stds.h>
 }
 
+#include "../afsapplib/afsapplib.h"
+
 #include "svrmgr.h"
 #include "cmdline.h"
 #include "action.h"
@@ -32,6 +34,7 @@ typedef enum {
    swUSER,
    swPASSWORD,
    swLOOKUP,
+   swUSEEXISTING
 } SWITCH;
 
 static struct {
@@ -40,14 +43,15 @@ static struct {
    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("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]))
@@ -251,6 +255,36 @@ CMDLINEOP ParseCommandLine (LPTSTR pszCmdLine)
       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)
       {
       LPOPENCELL_PACKET lpp = New (OPENCELL_PACKET);