This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[no subject]
- Http: //stackoverflow.com/questions/4785126/getlogin-c-function-returns-null-and-error-no-such-file-or-directory/4785195#4785195
:
Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <systemtap.sourceware.org>
List-Unsubscribe: <mailto:systemtap-unsubscribe-##L=##H@sourceware.org>
List-Subscribe: <mailto:systemtap-subscribe@sourceware.org>
List-Post: <mailto:systemtap@sourceware.org>
List-Help: <mailto:systemtap-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: systemtap-owner@sourceware.org
Delivered-To: mailing list systemtap@sourceware.org
|getlogin| is an unsafe and deprecated way of determining the logged-in
user. It's probably trying to open a record of logged-in users, perhaps
|utmp| or something. The correct way to determine the user you're
running as (which might not be the same as the logged-in user, but is
almost always better to use anyway) is |getpwuid(getuid())|
So after I replaced
string login = getlogin ();
with
struct passwd *pwd;
pwd = getpwuid(getuid());
string login = pwd->pw_name;
I can now manualy run
./stap-serverd
without std::logic_error
Looks like this bug is specific ether to Ubuntu or my setup.
I hope to find time to finish my script next week and provide a patch
for getlogin and whatever else will show up.
Probably replacing getlogin() call is a good idea anyway.
Thanks,
Alex
On 10/20/2011 04:28 PM, Josh Stone wrote:
> On 10/20/2011 12:57 PM, Alex Wolfson wrote:
>> 3. Attempt to manually start the daemon
>> -------------------------------------------------------
>> awolfson@awolfson-T410:/usr/lib/systemtap$ ./stap-serverd
>> terminate called after throwing an instance of 'std::logic_error'
>> what(): basic_string::_S_construct null not valid
>> Aborted
> I believe that's a programming error, trying to initialize some string
> with a (char*)NULL.
>
>> Sorry for that long Email, but I would be greatly apReceived: (qmail 17974 invoked by uid 22791); 21 Oct 2011 02:05:12 -0000
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD
X-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Received: from youngberry.canonical.com (HELO youngberry.canonical.com) (91.189.89.112) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Oct 2011 02:04:57 +0000
Received: from pool-173-76-98-227.bstnma.fios.verizon.net ([173.76.98.227] helo=[192.168.1.4]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <alex.wolfson@canonical.com>) id 1RH4Tg-0005VU-0P for systemtap@sourceware.org; Fri, 21 Oct 2011 02:04:56 +0000
Message-ID: <4EA0D345.5000305@canonical.com>
Date: Thu, 20 Oct 2011 22:04:53 -0400
From: Alex Wolfson <alex.wolfson@canonical.com>
Organization: Canonical
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
To: systemtap@sourceware.org
Subject: Re: Problem setting up systemtap 1.6 client/server on Ubutu 11.10
References: <4EA07D2E.3070205@canonical.com> <4EA0847E.5070109@redhat.com>
In-Reply-To: <4EA0847E.5070109@redhat.com>
Content-Type: multipart/alternative; boundary="------------020608050208060507060203"
X-Virus-Checked: Checked by ClamAV on sourceware.org
X-IsSubscribed: yes
This is a multi-part message in MIME format.
--------------020608050208060507060203
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi Josh,
Thank you for the feedback.
I found the place when stap-serverd is failing
it is in stap-serverd.cxx
static void
initialize (int argc, char **argv) {
.....
string login = getlogin ();
getlogin returns NULL
--------------020608050208060507060203--