// _RequestThread int32 AuthenticationServer::_RequestThread() { TaskManager taskManager; while (!fTerminating) { taskManager.RemoveDoneTasks(); // read the request KMessage request; status_t error = request.ReceiveFrom(fRequestPort); if (error != B_OK) continue; // get the parameters const char* context = NULL; const char* server = NULL; const char* share = NULL; bool badPassword = true; request.FindString("context", &context); request.FindString("server", &server); request.FindString("share", &share); request.FindBool("badPassword", &badPassword); if (!context || !server || !share) continue; String foundUser; String foundPassword; if (!badPassword && _GetAuthentication(context, server, share, &foundUser, &foundPassword)) { _SendRequestReply(request.ReplyPort(), request.ReplyToken(), error, false, foundUser.GetString(), foundPassword.GetString()); } else { // we need to ask the user: create a task that does it UserDialogTask* task = new(nothrow) UserDialogTask(this, context, server, share, badPassword, request.ReplyPort(), request.ReplyToken()); if (!task) { ERROR(("AuthenticationServer::_RequestThread(): ERROR: " "failed to allocate ")); continue; } status_t error = taskManager.RunTask(task); if (error != B_OK) { ERROR(("AuthenticationServer::_RequestThread(): Failed to " "start server info task: %s\n", strerror(error))); continue; } } } return 0; }
int getspnam_r(const char *name, struct spwd *spwd, char *buffer, size_t bufferSize, struct spwd **_result) { *_result = NULL; KMessage message(BPrivate::B_REG_GET_USER); message.AddString("name", name); message.AddBool("shadow", true); KMessage reply; status_t error = BPrivate::send_authentication_request_to_registrar(message, reply); if (error != B_OK) return error; const char* password; int32 lastChanged; int32 min; int32 max; int32 warn; int32 inactive; int32 expiration; int32 flags; if ((error = reply.FindString("name", &name)) != B_OK || (error = reply.FindString("shadow password", &password)) != B_OK || (error = reply.FindInt32("last changed", &lastChanged)) != B_OK || (error = reply.FindInt32("min", &min)) != B_OK || (error = reply.FindInt32("max", &max)) != B_OK || (error = reply.FindInt32("warn", &warn)) != B_OK || (error = reply.FindInt32("inactive", &inactive)) != B_OK || (error = reply.FindInt32("expiration", &expiration)) != B_OK || (error = reply.FindInt32("flags", &flags)) != B_OK) { return error; } error = BPrivate::copy_shadow_pwd_to_buffer(name, password, lastChanged, min, max, warn, inactive, expiration, flags, spwd, buffer, bufferSize); if (error == B_OK) *_result = spwd; return error; }
static status_t query_group_entry(const char* name, gid_t _gid, struct group *group, char *buffer, size_t bufferSize, struct group **_result) { *_result = NULL; KMessage message(BPrivate::B_REG_GET_GROUP); if (name) message.AddString("name", name); else message.AddInt32("gid", _gid); KMessage reply; status_t error = BPrivate::send_authentication_request_to_registrar(message, reply); if (error != B_OK) return error; int32 gid; const char* password; if ((error = reply.FindInt32("gid", &gid)) != B_OK || (error = reply.FindString("name", &name)) != B_OK || (error = reply.FindString("password", &password)) != B_OK) { return error; } const char* members[MAX_GROUP_MEMBER_COUNT]; int memberCount = 0; for (int memberCount = 0; memberCount < MAX_GROUP_MEMBER_COUNT;) { if (reply.FindString("members", members + memberCount) != B_OK) break; memberCount++; } error = BPrivate::copy_group_to_buffer(name, password, gid, members, memberCount, group, buffer, bufferSize); if (error == B_OK) *_result = group; return error; }
bool Shell::GetActiveProcessInfo(ActiveProcessInfo& _info) const { _info.Unset(); // get the foreground process group pid_t process = tcgetpgrp(fFd); if (process < 0) return false; // get more info on the process group leader KMessage info; status_t error = get_extended_team_info(process, B_TEAM_INFO_BASIC, info); if (error != B_OK) return false; // fetch the name and the current directory from the info const char* name; int32 cwdDevice; int64 cwdDirectory; if (info.FindString("name", &name) != B_OK || info.FindInt32("cwd device", &cwdDevice) != B_OK || info.FindInt64("cwd directory", &cwdDirectory) != B_OK) { return false; } // convert the node ref into a path entry_ref cwdRef(cwdDevice, cwdDirectory, "."); BPath cwdPath; if (cwdPath.SetTo(&cwdRef) != B_OK) return false; // set the result _info.SetTo(process, name, cwdPath.Path()); return true; }