зеркало из https://github.com/mozilla/gecko-dev.git
1) XP_UNIX should use getenv("LOGNAME") instead of getpwuid(geteuid())
since the same UID may be shared by multiple logins (yes, really!). 2) fix bug in ipcmMessageClientInfo::NextTarget().
This commit is contained in:
Родитель
f8075b962f
Коммит
9dcebf21ea
|
@ -197,10 +197,9 @@ ipcmMessageClientInfo::NextTarget(const nsID *target) const
|
|||
ipcmClientInfoHeader *hdr = (ipcmClientInfoHeader *) Data();
|
||||
|
||||
if (!target)
|
||||
return (const nsID *) hdr + hdr->mTargetStart;
|
||||
return (const nsID *) (Data() + hdr->mTargetStart);
|
||||
|
||||
target += sizeof(nsID);
|
||||
if (target == (const nsID *) MsgBuf() + MsgLen())
|
||||
if (++target == (const nsID *) (MsgBuf() + MsgLen()))
|
||||
target = NULL;
|
||||
return target;
|
||||
}
|
||||
|
|
|
@ -161,14 +161,14 @@ ipcService::OnIPCMClientInfo(const ipcmMessageClientInfo *msg)
|
|||
PRUint32 targetCount = msg->TargetCount();
|
||||
PRUint32 i;
|
||||
|
||||
const char **names = (const char **) calloc(nameCount + 1, sizeof(const char *));
|
||||
const char **names = (const char **) calloc(nameCount, sizeof(char *));
|
||||
const char *lastName = NULL;
|
||||
for (i = 0; i < nameCount; ++i) {
|
||||
lastName = msg->NextName(lastName);
|
||||
names[i] = lastName;
|
||||
}
|
||||
|
||||
const nsID **targets = (const nsID **) calloc(targetCount + 1, sizeof(const nsID *));
|
||||
const nsID **targets = (const nsID **) calloc(targetCount, sizeof(nsID *));
|
||||
const nsID *lastTarget = NULL;
|
||||
for (i = 0; i < targetCount; ++i) {
|
||||
lastTarget = msg->NextTarget(lastTarget);
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "prenv.h"
|
||||
|
||||
#include "nsIFile.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -200,13 +198,19 @@ ipcTransport::GetSocketPath(nsACString &socketPath)
|
|||
NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
||||
if (!file)
|
||||
return NS_ERROR_FAILURE;
|
||||
// XXX may want to use getpwuid_r when available
|
||||
struct passwd *pw = getpwuid(geteuid());
|
||||
if (!pw)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
const char *logName = PR_GetEnv("LOGNAME");
|
||||
if (!(logName && *logName)) {
|
||||
logName = PR_GetEnv("USER");
|
||||
if (!(logName && *logName)) {
|
||||
LOG(("could not determine username from environment\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCAutoString leaf;
|
||||
leaf = NS_LITERAL_CSTRING(".mozilla-ipc-")
|
||||
+ nsDependentCString(pw->pw_name);
|
||||
+ nsDependentCString(logName);
|
||||
file->AppendNative(leaf);
|
||||
file->AppendNative(NS_LITERAL_CSTRING("ipcd"));
|
||||
file->GetNativePath(socketPath);
|
||||
|
|
|
@ -48,8 +48,4 @@ LIBS = \
|
|||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../util \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -44,6 +44,14 @@
|
|||
#include "nsString.h"
|
||||
#include "prmem.h"
|
||||
|
||||
static const nsID kIPCMTargetID =
|
||||
{ /* 753ca8ff-c8c2-4601-b115-8c2944da1150 */
|
||||
0x753ca8ff,
|
||||
0xc8c2,
|
||||
0x4601,
|
||||
{0xb1, 0x15, 0x8c, 0x29, 0x44, 0xda, 0x11, 0x50}
|
||||
};
|
||||
|
||||
static const nsID kTestTargetID =
|
||||
{ /* e628fc6e-a6a7-48c7-adba-f241d1128fb8 */
|
||||
0xe628fc6e,
|
||||
|
@ -144,8 +152,15 @@ myIpcClientObserver::OnClientInfo(PRUint32 aReqToken,
|
|||
printf("*** %d={%s}\n", i, aNames[i]);
|
||||
printf("*** targets:\n");
|
||||
for (i = 0; i < aTargetCount; ++i) {
|
||||
const char *trailer;
|
||||
if (aTargets[i]->Equals(kTestTargetID))
|
||||
trailer = " (TEST_TARGET_ID)";
|
||||
else if (aTargets[i]->Equals(kIPCMTargetID))
|
||||
trailer = " (IPCM_TARGET_ID)";
|
||||
else
|
||||
trailer = " (unknown)";
|
||||
char *str = aTargets[i]->ToString();
|
||||
printf("*** %d=%s\n", i, str);
|
||||
printf("*** %d=%s%s\n", i, str, trailer);
|
||||
PR_Free(str);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче