]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: remove unused code in ntlm_sspi_auth (#1627)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Thu, 28 Dec 2023 17:05:37 +0000 (17:05 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 29 Dec 2023 00:48:09 +0000 (00:48 +0000)
src/auth/ntlm/SSPI/ntlm_sspi_auth.cc

index 89c8f898e4f0471b9916627e8e36f08d334f3252..f9f44d1d0a074d6414c9d0f797add9debdad8ebf 100644 (file)
@@ -164,115 +164,6 @@ Valid_Group(char *UserName, char *Group)
     return result;
 }
 
-char * AllocStrFromLSAStr(LSA_UNICODE_STRING LsaStr)
-{
-    size_t len;
-    static char * target;
-
-    len = LsaStr.Length/sizeof(WCHAR) + 1;
-
-    /* allocate buffer for str + null termination */
-    safe_free(target);
-    target = (char *)xmalloc(len);
-    if (target == NULL)
-        return nullptr;
-
-    /* copy unicode buffer */
-    WideCharToMultiByte(CP_ACP, 0, LsaStr.Buffer, LsaStr.Length, target, len, nullptr, nullptr);
-
-    /* add null termination */
-    target[len-1] = '\0';
-    return target;
-}
-
-char * GetDomainName(void)
-
-{
-    LSA_HANDLE PolicyHandle;
-    LSA_OBJECT_ATTRIBUTES ObjectAttributes;
-    NTSTATUS status;
-    PPOLICY_PRIMARY_DOMAIN_INFO ppdiDomainInfo;
-    PWKSTA_INFO_100 pwkiWorkstationInfo;
-    DWORD netret;
-    char * DomainName = nullptr;
-
-    /*
-     * Always initialize the object attributes to all zeroes.
-     */
-    memset(&ObjectAttributes, '\0', sizeof(ObjectAttributes));
-
-    /*
-     * You need the local workstation name. Use NetWkstaGetInfo at level
-     * 100 to retrieve a WKSTA_INFO_100 structure.
-     *
-     * The wki100_computername field contains a pointer to a UNICODE
-     * string containing the local computer name.
-     */
-    netret = NetWkstaGetInfo(nullptr, 100, (LPBYTE *)&pwkiWorkstationInfo);
-    if (netret == NERR_Success) {
-        /*
-         * We have the workstation name in:
-         * pwkiWorkstationInfo->wki100_computername
-         *
-         * Next, open the policy object for the local system using
-         * the LsaOpenPolicy function.
-         */
-        status = LsaOpenPolicy(
-                     nullptr,
-                     &ObjectAttributes,
-                     GENERIC_READ | POLICY_VIEW_LOCAL_INFORMATION,
-                     &PolicyHandle
-                 );
-
-        /*
-         * Error checking.
-         */
-        if (status) {
-            debug("OpenPolicy Error: %ld\n", status);
-        } else {
-
-            /*
-             * You have a handle to the policy object. Now, get the
-             * domain information using LsaQueryInformationPolicy.
-             */
-            status = LsaQueryInformationPolicy(PolicyHandle,
-                                               PolicyPrimaryDomainInformation,
-                                               (void **)&ppdiDomainInfo);
-            if (status) {
-                debug("LsaQueryInformationPolicy Error: %ld\n", status);
-            } else  {
-
-                /* Get name in usable format */
-                DomainName = AllocStrFromLSAStr(ppdiDomainInfo->Name);
-
-                /*
-                 * Check the Sid pointer, if it is null, the
-                 * workstation is either a stand-alone computer
-                 * or a member of a workgroup.
-                 */
-                if (ppdiDomainInfo->Sid) {
-
-                    /*
-                     * Member of a domain. Display it in debug mode.
-                     */
-                    debug("Member of Domain %s\n",DomainName);
-                } else {
-                    DomainName = nullptr;
-                }
-            }
-        }
-
-        /*
-         * Clean up all the memory buffers created by the LSA and
-         * Net* APIs.
-         */
-        NetApiBufferFree(pwkiWorkstationInfo);
-        LsaFreeMemory((LPVOID)ppdiDomainInfo);
-    } else
-        debug("NetWkstaGetInfo Error: %ld\n", netret);
-    return DomainName;
-}
-
 /*
  * Fills auth with the user's credentials.
  *