oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString *strPasswd, oslSecurity *pSecurity ) { oslSecurityError ret; if (!isWNT()) { *pSecurity = osl_getCurrentSecurity(); ret = osl_Security_E_None; } else { sal_Unicode* strUser; sal_Unicode* strDomain = _wcsdup(rtl_uString_getStr(strUserName)); HANDLE hUserToken; #if OSL_DEBUG_LEVEL > 0 LUID luid; #endif if (NULL != (strUser = wcschr(strDomain, L'/'))) *strUser++ = L'\0'; else { strUser = strDomain; strDomain = NULL; } // this process must have the right: 'act as a part of operatingsystem' OSL_ASSERT(LookupPrivilegeValue(NULL, SE_TCB_NAME, &luid)); if (LogonUserW(strUser, strDomain ? strDomain : L"", rtl_uString_getStr(strPasswd), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken)) { oslSecurityImpl* pSecImpl = malloc(sizeof(oslSecurityImpl)); pSecImpl->m_pNetResource = NULL; pSecImpl->m_hToken = hUserToken; pSecImpl->m_hProfile = NULL; wcscpy(pSecImpl->m_User, strUser); *pSecurity = (oslSecurity)pSecImpl; ret = osl_Security_E_None; } else ret = osl_Security_E_UserUnknown; if (strDomain) free(strDomain); else free(strUser); } return ret; }
/* * Class: com_sun_star_lib_connections_pipe_PipeConnection * Method: connect * Signature: (Lcom/sun/star/beans/NativeService;)V */ SAL_DLLPUBLIC_EXPORT void #if defined WNT PipeConnection_create #else JNICALL Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI #endif (JNIEnv * env, jobject obj_this, jstring name) { enum { START = 0, INMONITOR, GOTNAME, CREATED }; short state = START; jclass tclass; jfieldID fid; oslSecurity psec = osl_getCurrentSecurity(); oslPipe npipe = NULL; rtl_uString * pname = NULL; if ((*env)->MonitorEnter(env, obj_this) != 0) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot synchronize on the object"); goto error; } state = INMONITOR; /* check connection state */ npipe = getPipe(env, obj_this); if ((*env)->ExceptionOccurred(env) != NULL) goto error; if (npipe != NULL) { ThrowException(env, "com/sun/star/io/IOException", "native pipe is already connected"); goto error; } /* save the pipe name */ tclass = (*env)->GetObjectClass(env, obj_this); if (tclass == NULL) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot find class"); goto error; } fid = (*env)->GetFieldID(env, tclass, "_aDescription", "Ljava/lang/String;"); if (fid == NULL) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot find field"); goto error; } (*env)->SetObjectField(env, obj_this, fid, (jobject)name); /* convert pipe name to rtl_uString */ pname = jstring2ustring(env, name); if (pname == NULL) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot convert name"); goto error; } state = GOTNAME; /* try to connect */ npipe = osl_createPipe(pname, osl_Pipe_OPEN, psec); if (npipe == NULL) { ThrowException(env, "java/lang/RuntimeException", "cannot create native pipe"); goto error; } state = CREATED; /* save the pipe */ tclass = (*env)->GetObjectClass(env, obj_this); if (tclass == NULL) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot find class"); goto error; } fid = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J"); if (fid == NULL) { ThrowException(env, "java/lang/RuntimeException", "native pipe cannot find field"); goto error; } (*env)->SetLongField( env, obj_this, fid, SAL_INT_CAST(jlong, (sal_IntPtr) npipe)); /* done */ rtl_uString_release(pname); (*env)->MonitorExit(env, obj_this); osl_freeSecurityHandle(psec); return; error: switch (state) { case CREATED: osl_closePipe(npipe); osl_releasePipe(npipe); case GOTNAME: rtl_uString_release(pname); case INMONITOR: (*env)->MonitorExit(env, obj_this); case START: osl_freeSecurityHandle(psec); default: break; } return; }