Print this page
1575 untangle libmlrpc ... pre2:
 Get rid of ndr_rpc_server_{info,os}


 174 
 175         (void) memcpy(&arg.client_challenge, &netr_info->client_challenge,
 176             sizeof (struct netr_credential));
 177 
 178         if (ndr_rpc_call(netr_handle, opnum, &arg) != 0)
 179                 return (-1);
 180 
 181         if (arg.status != 0) {
 182                 ndr_rpc_status(netr_handle, opnum, arg.status);
 183                 ndr_rpc_release(netr_handle);
 184                 return (-1);
 185         }
 186 
 187         (void) memcpy(&netr_info->server_challenge, &arg.server_challenge,
 188             sizeof (struct netr_credential));
 189 
 190         ndr_rpc_release(netr_handle);
 191         return (0);
 192 }
 193 




 194 /*
 195  * netr_server_authenticate2
 196  */
 197 static int
 198 netr_server_authenticate2(mlsvc_handle_t *netr_handle, netr_info_t *netr_info)
 199 {
 200         struct netr_ServerAuthenticate2 arg;
 201         /* sizeof netr_info->hostname, + 1 for the '$' */
 202         char account_name[(NETBIOS_NAME_SZ * 2) + 1];
 203         int opnum;
 204         int rc;
 205 
 206         bzero(&arg, sizeof (struct netr_ServerAuthenticate2));
 207         opnum = NETR_OPNUM_ServerAuthenticate2;
 208 
 209         (void) snprintf(account_name, sizeof (account_name), "%s$",
 210             netr_info->hostname);
 211 
 212         smb_tracef("server=[%s] account_name=[%s] hostname=[%s]\n",
 213             netr_info->server, account_name, netr_info->hostname);
 214 
 215         arg.servername = (unsigned char *)netr_info->server;
 216         arg.account_name = (unsigned char *)account_name;
 217         arg.account_type = NETR_WKSTA_TRUST_ACCOUNT_TYPE;
 218         arg.hostname = (unsigned char *)netr_info->hostname;
 219         arg.negotiate_flags = NETR_NEGOTIATE_BASE_FLAGS;
 220 
 221         if (ndr_rpc_server_os(netr_handle) == NATIVE_OS_WIN2000) {
 222                 arg.negotiate_flags |= NETR_NEGOTIATE_STRONGKEY_FLAG;
 223                 if (netr_gen_skey128(netr_info) != SMBAUTH_SUCCESS)
 224                         return (-1);
 225         } else {
 226                 if (netr_gen_skey64(netr_info) != SMBAUTH_SUCCESS)
 227                         return (-1);
 228         }
 229 
 230         if (netr_gen_credentials(netr_info->session_key.key,
 231             &netr_info->client_challenge, 0,
 232             &netr_info->client_credential) != SMBAUTH_SUCCESS) {
 233                 return (-1);
 234         }
 235 
 236         if (netr_gen_credentials(netr_info->session_key.key,
 237             &netr_info->server_challenge, 0,
 238             &netr_info->server_credential) != SMBAUTH_SUCCESS) {
 239                 return (-1);
 240         }
 241 
 242         (void) memcpy(&arg.client_credential, &netr_info->client_credential,




 174 
 175         (void) memcpy(&arg.client_challenge, &netr_info->client_challenge,
 176             sizeof (struct netr_credential));
 177 
 178         if (ndr_rpc_call(netr_handle, opnum, &arg) != 0)
 179                 return (-1);
 180 
 181         if (arg.status != 0) {
 182                 ndr_rpc_status(netr_handle, opnum, arg.status);
 183                 ndr_rpc_release(netr_handle);
 184                 return (-1);
 185         }
 186 
 187         (void) memcpy(&netr_info->server_challenge, &arg.server_challenge,
 188             sizeof (struct netr_credential));
 189 
 190         ndr_rpc_release(netr_handle);
 191         return (0);
 192 }
 193 
 194 uint32_t netr_server_auth2_flags =
 195     NETR_NEGOTIATE_BASE_FLAGS |
 196     NETR_NEGOTIATE_STRONGKEY_FLAG;
 197 
 198 /*
 199  * netr_server_authenticate2
 200  */
 201 static int
 202 netr_server_authenticate2(mlsvc_handle_t *netr_handle, netr_info_t *netr_info)
 203 {
 204         struct netr_ServerAuthenticate2 arg;
 205         /* sizeof netr_info->hostname, + 1 for the '$' */
 206         char account_name[(NETBIOS_NAME_SZ * 2) + 1];
 207         int opnum;
 208         int rc;
 209 
 210         bzero(&arg, sizeof (struct netr_ServerAuthenticate2));
 211         opnum = NETR_OPNUM_ServerAuthenticate2;
 212 
 213         (void) snprintf(account_name, sizeof (account_name), "%s$",
 214             netr_info->hostname);
 215 
 216         smb_tracef("server=[%s] account_name=[%s] hostname=[%s]\n",
 217             netr_info->server, account_name, netr_info->hostname);
 218 
 219         arg.servername = (unsigned char *)netr_info->server;
 220         arg.account_name = (unsigned char *)account_name;
 221         arg.account_type = NETR_WKSTA_TRUST_ACCOUNT_TYPE;
 222         arg.hostname = (unsigned char *)netr_info->hostname;
 223         arg.negotiate_flags = netr_server_auth2_flags;
 224 
 225         if (arg.negotiate_flags & NETR_NEGOTIATE_STRONGKEY_FLAG) {

 226                 if (netr_gen_skey128(netr_info) != SMBAUTH_SUCCESS)
 227                         return (-1);
 228         } else {
 229                 if (netr_gen_skey64(netr_info) != SMBAUTH_SUCCESS)
 230                         return (-1);
 231         }
 232 
 233         if (netr_gen_credentials(netr_info->session_key.key,
 234             &netr_info->client_challenge, 0,
 235             &netr_info->client_credential) != SMBAUTH_SUCCESS) {
 236                 return (-1);
 237         }
 238 
 239         if (netr_gen_credentials(netr_info->session_key.key,
 240             &netr_info->server_challenge, 0,
 241             &netr_info->server_credential) != SMBAUTH_SUCCESS) {
 242                 return (-1);
 243         }
 244 
 245         (void) memcpy(&arg.client_credential, &netr_info->client_credential,