[#4346] Segmentation fault — Andrew Walrond <andrew@...>
FYI, just got this random unexpected crash
On 01 Feb 2005, at 07:33, Andrew Walrond wrote:
[#4360] Adding lastlog info to etc — "Berger, Daniel" <Daniel.Berger@...>
Hi all,
[#4368] 'when (cond):' causes SyntaxError — "NAKAMURA, Hiroshi" <nakahiro@...>
Hi,
[#4385] add color_set support to curses.c — Paul Duncan <pabs@...>
I'm not sure why this is missing from the Curses binding, but the
[#4392] HTTP Basic authentication for open_uri — Kent Sibilev <ksibilev@...>
Can somebody apply the following patch for open_uri in order to enable
[#4402] BUG: Struct.new(:a?).instance_methods — "Cs. Henk" <csaba-ml@...>
Hi, getting an ArgumentError with "NULL pointer given" doesn't seem to
[#4403] Re: Unknown OS X 10.2 Socket constants (+script to generate) — Sam Roberts <sroberts@...>
Quoteing matz@ruby-lang.org, on Tue, Feb 08, 2005 at 01:21:18PM +0900:
[#4427] Re: windows socket connection freeze — ville.mattila@...
[#4432] curses + threads = non-blocking getch — William Morgan <wmorgan-ruby-core@...>
Hello experts,
In article <20050214231544.GE26414@masanjin.net>,
[#4439] Thread-safe Ruby Status? — Vincent Isambart <vincent.isambart@...>
Hello,
[#4448] add persistent history to irb — "David A. Black" <dblack@...>
Hi --
[#4453] bug in IRB with $_ matching a range of regexps — Ryan Davis <ryand-ruby@...>
> % ruby -v
[#4468] Re: Strange argc check in stable snapshot — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
[#4475] Re: Strange argc check in stable snapshot — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
[#4479] Requesting addition to IRB (configurable standard output) — Sascha Ebach <se@...>
Hello,
Quoting se@digitale-wertschoepfung.de, on Fri, Feb 25, 2005 at 01:22:34AM +0900:
On 24 Feb 2005, at 19:51, Sam Roberts wrote:
Quoting drbrain@segment7.net, on Sat, Feb 26, 2005 at 02:43:31AM +0900:
On 25 Feb 2005, at 16:03, Sam Roberts wrote:
Quoting drbrain@segment7.net, on Sat, Feb 26, 2005 at 10:24:52AM +0900:
On 25 Feb 2005, at 18:55, Sam Roberts wrote:
Quoting drbrain@segment7.net, on Sat, Feb 26, 2005 at 03:49:49PM +0900:
Adding lastlog info to etc
Hi all,
Any chance of adding lastlog information to the etc module? I have a
patch, but it only works for Solaris at the moment. Basically, it means
altering the extconf.rb file and doing the following:
Look for a last_log struct in utmp.h.
If it's not there, look for a lastlog.h file.
If either of these are present, then check for the ll_time struct member
(doesn't appear to be defined in Linux, but is defined in Solaris and
FreeBSD).
Within etc.c:
Use appropriate macros derived from extconf.rb.
Point the lastlog name to _PATH_LASTLOG if present. If not, use
"/var/adm/lastlog".
Add the time (ll_time, if present), device name (ll_line) and host info
(ll_host) to the data returned by Etc.passwd.
Does this sound like a good idea?
I've included a Solaris patch below which works fine (just to
demonstrate), but needs adjustment for other Unix platforms.
Regards,
Dan
--- extconf.orig Wed Feb 2 11:55:35 2005
+++ extconf.rb Wed Feb 2 12:00:45 2005
@@ -14,5 +14,6 @@
have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
have_struct_member('struct group', 'gr_passwd', 'grp.h')
+ have_header("lastlog.h")
create_makefile("etc")
end
--- etc.bak Wed Feb 2 11:54:24 2005
+++ etc.c Wed Feb 2 13:02:53 2005
@@ -23,8 +23,17 @@
#include <grp.h>
#endif
+#ifdef HAVE_LASTLOG_H
+#include <lastlog.h>
+#include <fcntl.h>
+#endif
+
static VALUE sPasswd, sGroup;
+#ifdef HAVE_LASTLOG_H
+static struct lastlog* getllnam(const char* name);
+#endif
+
#ifndef _WIN32
char *getenv();
#endif
@@ -64,7 +73,18 @@
setup_passwd(pwd)
struct passwd *pwd;
{
+#ifdef HAVE_LASTLOG_H
+ struct lastlog* ll_entry;
+ time_t time;
+ VALUE rbTime = Qnil;
+#endif
if (pwd == 0) rb_sys_fail("/etc/passwd");
+#ifdef HAVE_LASTLOG_H
+ ll_entry = getllnam(pwd->pw_name);
+ time = ll_entry->ll_time;
+ if(time != 0)
+ rbTime = rb_time_new(time,0);
+#endif
return rb_struct_new(sPasswd,
safe_setup_str(pwd->pw_name),
#ifdef HAVE_ST_PW_PASSWD
@@ -95,6 +115,11 @@
#ifdef HAVE_ST_PW_EXPIRE
INT2FIX(pwd->pw_expire),
#endif
+#ifdef HAVE_LASTLOG_H
+ rbTime,
+ safe_setup_str(ll_entry->ll_line),
+ safe_setup_str(ll_entry->ll_host),
+#endif
0 /*dummy*/
);
}
@@ -157,7 +182,7 @@
struct passwd *pw;
setpwent();
- while (pw = getpwent()) {
+ while((pw = getpwent())) {
rb_yield(setup_passwd(pw));
}
endpwent();
@@ -180,7 +205,7 @@
passwd_blocking = Qtrue;
rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
}
- if (pw = getpwent()) {
+ if((pw = getpwent())) {
return setup_passwd(pw);
}
#endif
@@ -214,7 +239,7 @@
#ifdef HAVE_GETPWENT
struct passwd *pw;
- if (pw = getpwent()) {
+ if((pw = getpwent())) {
return setup_passwd(pw);
}
#endif
@@ -295,7 +320,7 @@
struct group *pw;
setgrent();
- while (pw = getgrent()) {
+ while((pw = getgrent())) {
rb_yield(setup_group(pw));
}
endgrent();
@@ -318,7 +343,7 @@
group_blocking = Qtrue;
rb_ensure(group_iterate, 0, group_ensure, 0);
}
- if (grp = getgrent()) {
+ if((grp = getgrent())) {
return setup_group(grp);
}
#endif
@@ -352,7 +377,7 @@
#ifdef HAVE_GETGRENT
struct group *gr;
- if (gr = getgrent()) {
+ if((gr = getgrent())) {
return setup_group(gr);
}
#endif
@@ -359,6 +384,24 @@
return Qnil;
}
+#ifdef HAVE_LASTLOG_H
+static struct lastlog* getllnam(const char* name){
+ static struct lastlog ll_entry;
+ struct passwd* pwd;
+ int fd;
+
+ if((fd = open("/var/adm/lastlog",O_RDONLY)) == -1)
+ rb_sys_fail("/var/adm/lastlog");
+
+ if((pwd = getpwnam(name)) == NULL)
+ rb_sys_fail("getpwnam failed");
+
+ pread(fd,&ll_entry,sizeof(struct lastlog),pwd->pw_uid *
sizeof(struct lastlog));
+ close(fd);
+ return (&ll_entry);
+}
+#endif
+
static VALUE mEtc;
void
@@ -406,6 +449,11 @@
#ifdef HAVE_ST_PW_EXPIRE
"expire",
#endif
+#ifdef HAVE_LASTLOG_H
+ "last_login",
+ "device_name",
+ "host_name",
+#endif
NULL);
rb_global_variable(&sPasswd);