summaryrefslogtreecommitdiff
path: root/sysutils/liboobs/patches/patch-ac
blob: 8b16ead5bf32e48fc24db559a4f591e5cd740a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$NetBSD: patch-ac,v 1.3 2009/07/12 10:33:12 hasso Exp $

--- oobs/oobs-user.c.orig	2008-01-02 16:23:56 +0200
+++ oobs/oobs-user.c	2009-07-12 10:44:15 +0300
@@ -18,13 +18,29 @@
  * Authors: Carlos Garnacho Parro  <carlosg@gnome.org>
  */
 
+#if defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
 #include <glib-object.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_CRYPT_H
 #include <crypt.h>
+#endif
+#ifndef __NetBSD__
 #include <utmp.h>
+#define UTMP utmp
+#define GETUTENT getutent
+#define ENDUTENT endutent
+#else
+#include <utmpx.h>
+#define UTMP utmpx
+#define GETUTENT getutxent
+#define ENDUTENT endutxent
+#endif
 
 #include "oobs-usersconfig.h"
 #include "oobs-user.h"
@@ -804,7 +820,7 @@ oobs_user_set_other_data (OobsUser *user
 gboolean
 oobs_user_get_active (OobsUser *user)
 {
-  struct utmp *entry;
+  struct UTMP *entry;
   const gchar *login;
   gboolean match = FALSE;
 
@@ -812,14 +828,16 @@ oobs_user_get_active (OobsUser *user)
 
   login = oobs_user_get_login_name (user);
 
-  while (!match && (entry = getutent ()) != NULL)
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
+  while (!match && (entry = GETUTENT ()) != NULL)
     {
       match = (entry->ut_type == USER_PROCESS &&
 	       strcmp (entry->ut_user, login) == 0);
     }
 
   /* close utmp */
-  endutent ();
+  ENDUTENT ();
 
   return match;
+#endif
 }