Changeset 855


Ignore:
Timestamp:
Mar 14, 2016, 12:01:47 PM (3 years ago)
Author:
mabarracus
Message:
  • Updated sources to 2.2.18
  • Ported code from patches to apply in 2.2.18
Location:
ldm/trunk
Files:
66 added
16 deleted
42 edited

Legend:

Unmodified
Added
Removed
  • ldm/trunk/fuentes/.pc/applied-patches

    r517 r855  
    11remove-hackish-gettext-function
    2 lliurex-patches
    3 ldm_verbose_ssh.patch
    4 ldm_background.patch
    5 profiled_thinclients
    6 other_languages
     2lliurex-patches_ported_from_2_2_13
     3ldm_verbose_patch_integrated_from_2_2_13
     4ldm_background_ported_from_2_2_13
     5profiled_thinclients_ported_from_2_2_13
     6other_languages_ported_from_2_2_13
  • ldm/trunk/fuentes/.pc/remove-hackish-gettext-function/share/ldm-script.in

    r516 r855  
    6060
    6161for SCRIPT in $(find -L $RCDIRS -type f -name "$SCRIPTS" -printf '%f\n' |
    62     tr ' ' '\n' | egrep ^[0-9a-zA-Z_\-]*$ | sort -u)
     62    tr ' ' '\n' | egrep ^[[:alnum:]_\-]*$ | sort -u)
    6363do
    6464    # only source the first instance of the script found
  • ldm/trunk/fuentes/ChangeLog

    r516 r855  
     1 1588 Vagrant Cascadian 2016-02-07 {ldm-2.2.18}
     2      Version 2.2.18
     3
     4 1587 Alkis Georgopoulos        2016-01-18
     5      Display LDM only in the first monitor (LP: #693151).
     6
     7 1586 Alkis Georgopoulos        2015-12-08
     8      DesktopNames replaced X-LightDM-DesktopName in xsession files
     9      (GNOME: #727546).
     10
     11 1585 Alkis Georgopoulos        2015-12-05
     12      "break" is not valid inside "case".
     13
     14 1584 Vagrant Cascadian 2015-10-08 {ldm-2.2.17}
     15      Version 2.2.17
     16
     17 1583 Vagrant Cascadian 2015-10-08
     18      screen.d/ldm: Rewrite test for LDM_DIRECTX to avoid using a negated
     19      boolean_is_true check.
     20
     21 1582 Alkis Georgopoulos        2015-10-08
     22      Xorg after 1.17 (not 1.16) needs `-listen tcp`.
     23
     24 1581 Alkis Georgopoulos        2015-10-03
     25      Xorg after 1.16 needs `-listen tcp`.
     26
     27 1580 Alkis Georgopoulos        2015-09-22
     28      ldm-script: fix regression from r1579, it needs [:alnum:], not
     29      [:alpha:].
     30
     31 1579 Alkis Georgopoulos        2015-09-02
     32      Replace [A-Za-z] with [:alpha:] to avoid locale issues (LP:
     33      #1491066).
     34
     35 1578 Vagrant Cascadian 2015-08-19 {ldm-2.2.16}
     36      Version 2.2.16
     37
     38 1577 Alkis Georgopoulos        2015-05-22
     39      Export DESKTOP_SESSION and XDG_CURRENT_DESKTOP to the client
     40      environment and try to avoid an empty LDM_SESSION.  These, along
     41      with r2646 from ltsp-client, make Unity work for both thin and fat
     42      clients in Ubuntu 14.04, and possibly fix other DE issues as well.
     43      The /etc/X11/Xsession.d/40-ltsp-{client|server} workarounds were
     44      not effective and can now be completely dropped from the Ubuntu
     45      packaging.
     46
     47 1576 Alkis Georgopoulos        2015-05-18
     48      Generalize LDM_12HOURCLOCK to LDM_CLOCK_FORMAT.
     49
     50 1575 Vagrant Cascadian 2015-02-01
     51      Remove rc.d hook to set LIBGL_ALWAYS_INDIRECT=true, as it causes
     52      problems with several common desktops, and can be enabled
     53      on a per-client basis by setting CLIENT_ENV in lts.conf.
     54      https://bugs.debian.org/767764
     55
     56 1574 Vagrant Cascadian 2014-10-21 {ldm-2.2.15}
     57      Version 2.2.15
     58
     59 1573 Vagrant Cascadian 2014-09-23
     60      dmrc-processing: Use do_ssh function rather than duplicating the
     61      ssh call.
     62
     63 1572 Vagrant Cascadian 2014-09-23
     64      dmrc-processing hook: Compare desktop session against local
     65      /usr/share/xsessions/*.desktop when running as a fat client.
     66      https://bugs.launchpad.net/ltsp/+bug/1272889
     67
     68 1571 Vagrant Cascadian 2014-09-23
     69      Remove further traces of halt-check hook.
     70
     71 1570 Vagrant Cascadian 2014-09-23
     72      Remove check for halting when SHUTDOWN_TIME is set, implemented
     73      in LTSP instead.  https://bugs.launchpad.net/ltsp/+bug/604908
     74
     75 1569 Jakob Unterwurzacher      2014-09-22
     76      ssh: Set ConnectTimeout=10
     77
     78      ConnectTimeout should be less than the timeout ssh_chat passes to
     79      expect, so we get the error message from ssh before expect gives up
     80      (30 seconds).
     81
     82      Also slightly increase the log level for spawning ssh to INFO.
     83
     84 1568 Jakob Unterwurzacher      2014-09-22
     85      ssh: Make sure expect() notices if ssh dies after finding a match
     86
     87      Before this patch, the error message "ssh: connect to host server
     88      port 22: Connection refused" was sometime mistaken as a prompt
     89      because it contains a colon.  This caused a 30 second delay.
     90
     91 1567 Jakob Unterwurzacher      2014-09-22
     92      ssh: expect() must handle EINTR
     93
     94      Otherwise, we do not capture the error message from ssh reliably as
     95      select() may be interrupted by SIGCHLD before we read the message.
     96
     97 1566 Jakob Unterwurzacher      2014-09-22
     98      ssh: Also log the error message from ssh
     99
     100 1565 Jakob Unterwurzacher      2014-09-22
     101      ssh: De-duplicate message handling code
     102
     103      Clean-up step for the previous patch.
     104
     105 1564 Jakob Unterwurzacher      2014-09-22
     106      ssh: Display specific error message if available
     107
     108      This way, we get a proper "Permission denied" for a wrong password.
     109      Horrible code duplication is fixed in the next patch.
     110
     111 1563 Jakob Unterwurzacher      2014-09-22
     112      ssh: Make expect() read all available data even if the child
     113      has exited
     114
     115      Implemented by checking if the child has exited *after* reading
     116      all data. That way, we capture the error message.
     117
     118 1562 Jakob Unterwurzacher      2014-09-22
     119      ssh: Remove superfluous timeout.tv_sec check in expect()
     120
     121      Timeout is already handled earlier. Checking for timeout.tv_sec ==
     122      0 is a bug as it may be zero under normal circumstances.
     123
     124 1561 Vagrant Cascadian 2014-09-20
     125      rc.d/I01-halt-check: Use poweroff instead of halt.
     126
     127 1560 Vagrant Cascadian 2014-09-20
     128      rc.d/I01-halt-check: Return if SHUTDOWN_TIME is not set.
     129
     130 1559 Vagrant Cascadian 2014-09-20
     131      rc.d/I01-halt-check: Explicitly return 0.
     132
     133 1558 Vagrant Cascadian 2014-09-11
     134      Fix typo: conditionally enable "-nolisten tcp" based on LDM_DIRECTX.
     135
     136 1557 Vagrant Cascadian 2014-09-10
     137      Disable listening on tcp, unless using LDM_DIRECTX. Thanks to
     138      Denis Croombs for reporting the issue!
     139
     140 1556 Vagrant Cascadian 2014-09-10
     141      Remove support for running without xinitrc.
     142
     143 1555 Vagrant Cascadian 2014-08-05 {ldm-2.2.14}
     144      version 2.2.14
     145
     146 1554 ben-Nabiy Derush  2014-07-31
     147      Updated according to vagrantc suggestions. Moved tests outside of
     148      function, reduced variables, so on...
     149
     150 1553 ben-Nabiy Derush  2014-07-31
     151      Added opt-in ssh_hashpass function
     152
     153 1552 ben-Nabiy Derush  2014-07-31
     154      Added ldm_getenv_bool_default
     155
     156 1551 ben-Nabiy Derush  2014-07-28
     157      Revised README-DEVELOPMENT-POLICY to clarify whitespace changes
     158      in existing code needing a separate merge request.
     159
     160 1550 ben-Nabiy Derush  2014-07-28
     161      indent -kr -i4 -nut -c50 -psl
     162
     163 1549 ben-Nabiy Derush  2014-07-28
     164      indent -kr -i4 -nut -c50 -psl
     165
     166 1548 ben-Nabiy Derush  2014-07-28
     167      indent -kr -i4 -nut -c50 -psl
     168
     169 1547 ben-Nabiy Derush  2014-07-28
     170      indent -kr -i4 -nut -c50 -psl
     171
     172 1546 ben-Nabiy Derush  2014-07-28
     173      indent -kr -i4 -nut -c50 -psl
     174
     175 1545 ben-Nabiy Derush  2014-07-28
     176      indent -kr -i4 -nut -c50 -psl
     177
    1178 1544 Vagrant Cascadian 2014-02-22 {ldm-2.2.13}
    2179      version 2.2.13
  • ldm/trunk/fuentes/README-DEVELOPMENT-POLICY

    r516 r855  
    2222     - Align inline comments on column 50
    2323     - A newline after function definitions
     24 - If you change whitespace or formatting of existing code, please do this in a
     25   separate merge proposal. This includes running the above indent command on
     26   existing code.
    2427 - All if() else blocks will have {}'s, even if only 1 line long, or Ollie will break your thumbs.
    2528 - Comments will be /* */ or Scott will break the rest of your fingers.
  • ldm/trunk/fuentes/configure.ac

    r516 r855  
    44
    55PACKAGE=ldm
    6 VERSION=2.2.13
     6VERSION=2.2.18
    77AUTHOR=sbalneav@ltsp.org
    88
  • ldm/trunk/fuentes/debian/changelog

    r518 r855  
    1 ldm (2:2.2.13-1+lliurex6) xenial; urgency=medium
    2 
    3   * Release into xenial
    4 
    5  -- M.Angel Juan <m.angel.juan@gmail.com>  Tue, 09 Feb 2016 17:37:06 +0100
    6 
    7 ldm (2:2.2.13-1+lliurex3) trusty; urgency=high
    8 
    9   * Adding profile.d to thin-clients
    10 
    11  -- Hector Garcia Huerta <hectorgh@gmail.com>  Mon, 03 Aug 2015 12:06:35 +0200
    12 
    13 ldm (2:2.2.13-1+lliurex2) trusty; urgency=medium
    14 
    15   * Adding more descriptive messages when login fails
    16 
    17  -- Hector Garcia Huerta <hectorgh@gmail.com>  Thu, 06 Nov 2014 12:51:54 +0100
    18 
    19 ldm (2:2.2.13-1+lliurex1) trusty; urgency=medium
    20 
    21   * LliureX changes
    22 
    23  -- Hector Garcia Huerta <hectorgh@gmail.com>  Tue, 07 Oct 2014 14:22:50 +0200
     1ldm (2:2.2.18-1) unstable; urgency=medium
     2
     3  * New upstream version.
     4    - Display LDM only in the first monitor (LP: #693151).
     5    - DesktopNames replaced X-LightDM-DesktopName in xsession files
     6      (GNOME: #727546).
     7    - Fix invalid syntax in .dmrc parsing the default session.
     8
     9  * debian/control: Update Vcs-Browser to use https URL.
     10
     11 -- Vagrant Cascadian <vagrant@debian.org>  Sun, 07 Feb 2016 11:51:40 -0800
     12
     13ldm (2:2.2.17-1) unstable; urgency=medium
     14
     15  * New upstream version:
     16    - ldm-script: Fix locale issues by matching against alphanumeric
     17      characters (LP: #1491066).
     18    - screen.d/ldm: Fix LDM_DIRECTX with Xorg 1.17+, which no longer opens
     19      a listening TCP socket by default (LP: #1449282).
     20
     21 -- Vagrant Cascadian <vagrant@debian.org>  Thu, 08 Oct 2015 13:59:43 -0700
     22
     23ldm (2:2.2.16-1) experimental; urgency=medium
     24
     25  * New upstream version:
     26    - Generalize LDM_12HOURCLOCK to LDM_CLOCK_FORMAT.
     27    - Export DESKTOP_SESSION and XDG_CURRENT_DESKTOP to the client.
     28  * Drop Remove-rc.d-hook-to-set-LIBGL_ALWAYS_INDIRECT-true-a.patch,
     29    applied upstream.
     30  * Use X-Vendor-Recommends to allow for variation between packages built
     31    on Ubuntu and Debian.
     32  * debian/copyright:
     33    - Reorder to fix lintian warnings and better follow copyright-format
     34      1.0.
     35    - Updated with newer copyright holders.
     36
     37 -- Vagrant Cascadian <vagrant@debian.org>  Wed, 19 Aug 2015 12:01:03 +0200
     38
     39ldm (2:2.2.15-2) unstable; urgency=medium
     40
     41  * Add patch to remove hook to set LIBGL_ALWAYS_INDIRECT=true, as it
     42    causes several common desktops to fail (Closes: #767764).
     43
     44 -- Vagrant Cascadian <vagrant@debian.org>  Sun, 08 Feb 2015 23:19:42 -0800
     45
     46ldm (2:2.2.15-1) unstable; urgency=medium
     47
     48  * New upstream version:
     49    - Display error message on failed login (LP: #1325388).
     50      Thanks to Jakob Unterwurzacher!
     51
     52    - Remove check for halting when SHUTDOWN_TIME is set, implemented in
     53      LTSP instead (LP: #604908).
     54
     55    - Compare desktop session against available local sessions when
     56      running as a fat client (LP: #1272889).
     57
     58  * debian/control: Update Standards-Version to 3.9.6, no changes needed.
     59  * Remove patch to disable listening on tcp, applied upstream.
     60  * Update debian/copyright.
     61 
     62 -- Vagrant Cascadian <vagrant@debian.org>  Wed, 22 Oct 2014 00:45:45 -0700
     63
     64ldm (2:2.2.14-2) unstable; urgency=medium
     65
     66  * Add patch from upstream to disable listening on tcp when not using
     67    LDM_DIRECTX.
     68
     69 -- Vagrant Cascadian <vagrant@debian.org>  Mon, 15 Sep 2014 14:09:56 -0500
     70
     71ldm (2:2.2.14-1) unstable; urgency=medium
     72
     73  * New upstream version:
     74    - Add feature to hash passwords for use with localapps and fat clients.
     75      Thanks to ben-Nabiy Derush.
     76
     77  * debian/rules:
     78    - Use dpkg-vendor --derives-from Ubuntu to set VENDOR,
     79      to better handle Debian/Ubuntu derivatives.
     80    - Allow architecture independent builds to succeed even if some files
     81      built by arch specific targets are missing.
     82
     83  * ldm-server: Recommend mate-desktop-environment in preference to other
     84    sessions.
     85
     86 -- Vagrant Cascadian <vagrant@debian.org>  Tue, 05 Aug 2014 22:38:48 -0700
    2487
    2588ldm (2:2.2.13-1) unstable; urgency=low
  • ldm/trunk/fuentes/debian/control

    r516 r855  
    66Build-Depends: debhelper (>= 9), flex, bison, libpopt-dev, libgtk2.0-dev,
    77  intltool, iso-codes, locales, python, dh-autoreconf, dctrl-tools
    8 Standards-Version: 3.9.5
     8Standards-Version: 3.9.6
    99Vcs-Bzr: nosmart+http://anonscm.debian.org/bzr/pkg-ltsp/ldm/ldm-debian-packaging/
    10 Vcs-Browser: http://anonscm.debian.org/loggerhead/pkg-ltsp/ldm/ldm-debian-packaging/files
     10Vcs-Browser: https://anonscm.debian.org/loggerhead/pkg-ltsp/ldm/ldm-debian-packaging/files
    1111Homepage: http://ltsp.org/
    1212
     
    3838 openssh-server,
    3939 update-inetd, openbsd-inetd | inet-superserver
    40 Recommends: ltspfs,
    41  gnome-session | x-session-manager | x-window-manager,
     40Recommends: ${vendor:Recommends},
     41 ltspfs,
    4242 libasound2-plugins,
    4343 xauth
     44X-Debian-Recommends: mate-desktop-environment | gnome-session | x-session-manager | x-window-manager
     45X-Ubuntu-Recommends: gnome-session | mate-desktop-environment | x-session-manager | x-window-manager
    4446Breaks: ltsp-server (<= 5.1.62)
    4547Replaces: ltsp-server (<= 5.1.62)
  • ldm/trunk/fuentes/debian/copyright

    r516 r855  
    44Upstream-Source: http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/
    55
     6Files: *
     7Copyright:
     8  2005-2015 Scott Balneaves and LTSP developers
     9License: GPL-2+
     10
    611Files: debian/*
    7 Copyright: 2007-2012 Vagrant Cascadian <vagrant@freegeek.org>
     12Copyright: 2007-2014 Vagrant Cascadian <vagrant@freegeek.org>
    813 2009 Ryan Niebur <ryanryan52@gmail.com>
     14License: GPL-2+
     15
     16Files: src/plugins/ssh/*
     17Copyright: 2014 Jakob Unterwurzacher <jakobunt@gmail.com>
     18 2014 ben-Nabiy Derush <bennabiy@parchmentpress.net>
     19 2012-2013 Alkis Georgopoulos <alkisg@gmail.com>
     20 2013 Scott Balneaves <sbalneav@phobos.legalaid.mb.ca>
     21 2010-2012 Stéphane Graber <stgraber@ubuntu.com>
     22 2012 Floris Bos / Maxnet <bos@je-eigen-domein.nl>
     23 2012 Vagrant Cascadian <vagrant@debian.org>
     24 2011 Warren Togami <warren@togami.com>
     25 2010 Simon Poirier <spoirier@revolutionlinux.com>
     26 2010 Vincent Vinet <vvinet@revolutionlinux.com>
    927License: GPL-2+
    1028
     
    2543 2008 Wolfgang Schweer <schweer@cityweb.de>
    2644 2008 Toshio Kuratomi
     45 2015 Alkis Georgopoulos <alkisg@gmail.com>
    2746License: GPL-2
    2847
     
    6685License: GPL-2+
    6786
    68 Files: src/sshutils.c
    69 Copyright: 2007-2008 Scott Balneaves <sbalneav@ltsp.org>
    70  2008 Ryan Niebur <RyanRyan52@gmail.com>
    71  2008 Warren Togami <wtogami@redhat.com>
    72  2008 Vagrant Cascadian <vagrant@freegeek.org>
    73  2008 Toshio Kuratomi
    74 License: GPL-2+
    75 
    76 Files: src/get_ip.c
    77 Copyright: 2007 Oliver Grawert <ogra@canonical.com>
    78  2008 Scott Balneaves <sbalneav@ltsp.org>
    79  2008 Warren Togami <wtogami@redhat.com>
    80  2008 Toshio Kuratomi
    81  2008-2009 Ryan Niebur <RyanRyan52@gmail.com>
    82 License: GPL-2
    83 
    84 Files: src/greeter_iface.c
    85 Copyright: 2007 Oliver Grawert <ogra@canonical.com>
    86  2007-2008 Scott Balneaves <sbalneav@ltsp.org>
    87  2007-2008 Vagrant Cascadian <vagrant@freegeek.org>
    88  2008 Ryan Niebur <RyanRyan52@gmail.com>
    89  2008 John Ellson <john.ellson@comcast.net>
    90  2008 Gideon Romm <gadi@ltsp.org>
    91  2008 Warren Togami <wtogami@redhat.com>
    92  2008 Francis Giraldeau <francis.giraldeau@revolutionlinux.com>
    93  2008 Toshio Kuratomi
    94 License: GPL-2+
    95 
    9687Files: src/ldminfo.c
    9788Copyright: 2007 Francis Giraldeau, <francis.giraldeau@revolutionlinux.com>
    9889 2007-2008 Scott Balneaves <sbalneav@ltsp.org>
    9990 2008-2009 Ryan Niebur <ryanryan52@gmail.com>
    100 License: GPL-2+
    101 
    102 Files: src/ldm-getenv-bool.c
    103 Copyright: 2007-2008 Scott Balneaves <sbalneav@ltsp.org>
    104  2008 Ryan Niebur <RyanRyan52@gmail.com>
    105  2008 Vagrant Cascadian <vagrant@freegeek.org>
     91 2014 ben-Nabiy Derush <bennabiy@parchmentpress.net>
     92 2015 Alkis Georgopoulos <alkisg@gmail.com>
    10693License: GPL-2+
    10794
  • ldm/trunk/fuentes/debian/patches/series

    r517 r855  
    11remove-hackish-gettext-function
    2 lliurex-patches
    3 ldm_verbose_ssh.patch
    4 ldm_background.patch
    5 profiled_thinclients
    6 other_languages
     2lliurex-patches_ported_from_2_2_13
     3ldm_verbose_patch_integrated_from_2_2_13
     4ldm_background_ported_from_2_2_13
     5profiled_thinclients_ported_from_2_2_13
     6other_languages_ported_from_2_2_13
  • ldm/trunk/fuentes/debian/rules

    r516 r855  
    33export ENABLE_NLS=1
    44
    5 VENDOR ?= $(shell dpkg-vendor --query Vendor)
     5VENDOR ?= $(shell dpkg-vendor --derives-from Ubuntu && echo Ubuntu || echo Debian)
    66
    77%:
     
    1010override_dh_install:
    1111        dh_install
    12         rm debian/ldm/usr/lib/*/ldm/*.la
     12        rm -f debian/ldm/usr/lib/*/ldm/*.la
    1313
    1414override_dh_fixperms:
    1515        dh_fixperms
    1616        # ensure ldm-script is executable to avoid lintian warning
    17         chmod +x debian/ldm/usr/share/ldm/ldm-script
     17        test ! -f debian/ldm/usr/share/ldm/ldm-script || chmod +x debian/ldm/usr/share/ldm/ldm-script
    1818
    1919override_dh_autoreconf:
  • ldm/trunk/fuentes/gtkgreet/greeter.c

    r516 r855  
    8080GList *host_list = NULL;
    8181GIOChannel *g_stdout;           /* stdout io channel */
    82 gchar * ldm_theme_dir;
     82gchar *ldm_theme_dir;
    8383
    8484int allowguest;
     
    8787
    8888gchar *
    89 ldm_theme_file(char * file)
    90 {
    91     gchar * filename;
    92     gchar * filename_default;
     89ldm_theme_file(char *file)
     90{
     91    gchar *filename;
     92    gchar *filename_default;
    9393    filename = g_strconcat("/", ldm_theme_dir, "/", file, NULL);
    94     filename_default = g_strconcat("/", LDM_THEME_DIR, "ltsp", "/", file, NULL);
    95     if (access(g_strconcat(filename, ".png", NULL), F_OK ) != -1)
    96     {
     94    filename_default =
     95        g_strconcat("/", LDM_THEME_DIR, "ltsp", "/", file, NULL);
     96    if (access(g_strconcat(filename, ".png", NULL), F_OK) != -1) {
    9797        filename = g_strconcat(filename, ".png", NULL);
    98     }
    99     else if (access(g_strconcat(filename, ".jpg", NULL), F_OK ) != -1)
    100     {
     98    } else if (access(g_strconcat(filename, ".jpg", NULL), F_OK) != -1) {
    10199        filename = g_strconcat(filename, ".jpg", NULL);
    102     }
    103     else if (access(g_strconcat(filename_default, ".png", NULL), F_OK ) != -1)
    104     {
     100    } else if (access(g_strconcat(filename_default, ".png", NULL), F_OK) !=
     101               -1) {
    105102        filename = g_strconcat(filename_default, ".png", NULL);
    106     }
    107     else if (access(g_strconcat(filename_default, ".jpg", NULL), F_OK ) != -1)
    108     {
     103    } else if (access(g_strconcat(filename_default, ".jpg", NULL), F_OK) !=
     104               -1) {
    109105        filename = g_strconcat(filename_default, ".jpg", NULL);
    110106    }
    111107    return filename;
    112108}
    113 GdkPixmap* root_bg = 0;
    114 void load_root_background(const gchar* filename, gboolean scale, gboolean reload) {
    115     if (root_bg != 0){
     109
     110void
     111get_default_display_size(gint * width, gint * height)
     112{
     113    GdkDisplay *display = NULL;
     114    GdkScreen *screen = NULL;
     115    GdkRectangle my_rect;
     116
     117    display = gdk_display_get_default();
     118    screen = gdk_display_get_default_screen(display);
     119    gdk_screen_get_monitor_geometry(screen, 0, &my_rect);
     120    *width = my_rect.width;
     121    *height = my_rect.height;
     122}
     123
     124GdkPixmap *root_bg = 0;
     125void
     126load_root_background(const gchar * filename, gboolean scale,
     127                     gboolean reload)
     128{
     129    if (root_bg != 0) {
    116130        if (reload) {
    117             g_object_unref(G_OBJECT (root_bg));
     131            g_object_unref(G_OBJECT(root_bg));
    118132            root_bg = 0;
    119133        } else {
     
    122136    }
    123137
    124     GtkWidget* image = gtk_image_new_from_file(filename);
    125     g_object_ref(G_OBJECT (image));
    126     GdkPixbuf* pixbuf = gtk_image_get_pixbuf(GTK_IMAGE (image));
    127     double img_width = (double)gdk_pixbuf_get_width(pixbuf);
    128     double img_height = (double)gdk_pixbuf_get_height(pixbuf);
    129 
    130     GdkWindow* root = gdk_get_default_root_window();
     138    GtkWidget *image = gtk_image_new_from_file(filename);
     139    g_object_ref(G_OBJECT(image));
     140    GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
     141    double img_width = (double) gdk_pixbuf_get_width(pixbuf);
     142    double img_height = (double) gdk_pixbuf_get_height(pixbuf);
     143
     144    GdkWindow *root = gdk_get_default_root_window();
    131145    gint width, height;
    132     gdk_drawable_get_size(GDK_DRAWABLE (root), &width, &height);
     146    get_default_display_size(&width, &height);
    133147
    134148    // create pixmap
    135     gdk_drawable_get_size(GDK_DRAWABLE (root), &width, &height);
    136     root_bg = gdk_pixmap_new(GDK_DRAWABLE (root), width, height, -1);
    137     g_object_ref(G_OBJECT (root_bg));
     149    root_bg = gdk_pixmap_new(GDK_DRAWABLE(root), width, height, -1);
     150    g_object_ref(G_OBJECT(root_bg));
    138151
    139152    // paint pixmap onto bg
    140     cairo_t* ctx = gdk_cairo_create(GDK_DRAWABLE (root_bg));
     153    cairo_t *ctx = gdk_cairo_create(GDK_DRAWABLE(root_bg));
    141154    if (scale) {
    142         cairo_scale(ctx, width/img_width, height/img_height);
     155        cairo_scale(ctx, width / img_width, height / img_height);
    143156    }
    144157    gdk_cairo_set_source_pixbuf(ctx, pixbuf, 0, 0);
     
    148161    //g_object_unref(G_OBJECT (bg));
    149162
    150     g_object_unref(G_OBJECT (image));
     163    g_object_unref(G_OBJECT(image));
    151164}
    152165
    153166void
    154 set_root_background() {
    155     GdkWindow* root = gdk_get_default_root_window();
    156 
    157 
    158     // bg needs to be set and painted, so it refreshes now and in the future
    159     gdk_window_set_back_pixmap(GDK_WINDOW (root), GDK_PIXMAP (root_bg), 0);
    160     gdk_draw_drawable(GDK_DRAWABLE (root),
    161                       gdk_gc_new(GDK_DRAWABLE (root)),
    162                       GDK_DRAWABLE (root_bg),
    163                       0, 0,
    164                       0, 0,
    165                       -1, -1);
    166 }
    167 
    168 void
    169 draw_background(GtkWidget* widget, gpointer data) {
    170     GdkWindow* window;
     167draw_background(GtkWidget * widget, gpointer data)
     168{
     169    GdkWindow *window;
    171170    gint width, height, x, y;
    172171
     
    175174        return;
    176175    }
    177     gdk_drawable_get_size(GDK_DRAWABLE (window), &width, &height);
    178     gdk_window_get_origin(GDK_WINDOW (window), &x, &y);
    179     GdkPixmap* new_bg = gdk_pixmap_new(root_bg, width, height, -1);
    180     g_object_ref(G_OBJECT (new_bg));
    181     gdk_draw_drawable(GDK_DRAWABLE (new_bg),
    182                     gdk_gc_new(GDK_DRAWABLE (new_bg)),
    183                     GDK_DRAWABLE (root_bg),
    184                     x, y,
    185                     0, 0,
    186                     width, height);
    187     gdk_window_set_back_pixmap(GDK_WINDOW (window), new_bg, 0);
    188 
    189     gtk_widget_queue_draw(GTK_WIDGET (widget));
     176    gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height);
     177    gdk_window_get_origin(GDK_WINDOW(window), &x, &y);
     178    GdkPixmap *new_bg = gdk_pixmap_new(root_bg, width, height, -1);
     179    g_object_ref(G_OBJECT(new_bg));
     180    gdk_draw_drawable(GDK_DRAWABLE(new_bg),
     181                      gdk_gc_new(GDK_DRAWABLE(new_bg)),
     182                      GDK_DRAWABLE(root_bg), x, y, 0, 0, width, height);
     183    gdk_window_set_back_pixmap(GDK_WINDOW(window), new_bg, 0);
     184
     185    gtk_widget_queue_draw(GTK_WIDGET(widget));
    190186}
    191187
     
    197193
    198194static void
    199 spawn_command(GtkWidget * widget, const gchar *command)
     195spawn_command(GtkWidget * widget, const gchar * command)
    200196{
    201197    GError **error = NULL;
     
    206202update_time(GtkWidget * label)
    207203{
    208     gchar *timestring = 0;
    209204    time_t timet;
    210205    struct tm *timePtr;
     206    gchar *clock_format;
     207    gchar label_markup[100];
    211208
    212209    timet = time(NULL);
    213210    timePtr = localtime(&timet);
    214211
    215     // use 12 hour clock format if LDM_12HOURCLOCK is set to true
    216     if (ldm_getenv_bool("LDM_12HOURCLOCK")) {
    217         timestring = g_strdup_printf("<b>%.2d:%.2d</b>",
    218                                    (timePtr->tm_hour % 12) ? (timePtr->tm_hour % 12) : 12,
    219                                    timePtr->tm_min);
    220     }
    221     else {
    222         timestring = g_strdup_printf("<b>%.2d:%.2d</b>",
    223                                    timePtr->tm_hour, timePtr->tm_min);
    224     }
    225 
    226     gtk_label_set_markup((GtkLabel *) label, timestring);
    227 
    228     g_free(timestring);
     212    // Allow the users to customize the clock format including the GTK markup,
     213    // for example in case they want the date non-bold and the time in bold.
     214    clock_format=ldm_getenv_str_default("LDM_CLOCK_FORMAT", "%x, <b>%H:%M</b>");
     215    if (strftime(label_markup, sizeof(label_markup), clock_format, timePtr))
     216        gtk_label_set_markup((GtkLabel *) label, label_markup);
    229217
    230218    return TRUE;
     
    236224    gchar *string;
    237225    int entry_length;
    238     entry_length = strlen(gtk_entry_get_text((GtkEntry *)entry));
    239     if(entry_length == 0 && timeout_enabled) {
    240         if (timeout_left > 1){
     226    entry_length = strlen(gtk_entry_get_text((GtkEntry *) entry));
     227    if (entry_length == 0 && timeout_enabled) {
     228        if (timeout_left > 1) {
    241229            timeout_left--;
    242230        } else if (timeout_left == 1) {
    243             g_io_channel_write_chars(g_stdout, "@GUEST@\n", -1, NULL, NULL);
     231            g_io_channel_write_chars(g_stdout, "@GUEST@\n", -1, NULL,
     232                                     NULL);
    244233            g_io_channel_flush(g_stdout, NULL);
    245234            timeout_left = 0;
    246235            timeout_enabled = FALSE;
    247         } else if (timeout_left == 0){
     236        } else if (timeout_left == 0) {
    248237            timeout_left = login_timeout;
    249238        }
    250         string = g_strdup_printf(_("Automatic login in %d seconds"), timeout_left);
     239        string =
     240            g_strdup_printf(_("Automatic login in %d seconds"),
     241                            timeout_left);
    251242        gtk_label_set_markup((GtkLabel *) label, string);
    252243        g_free(string);
     
    275266    gboolean result;
    276267
    277     result=gdk_property_get(
    278         gdk_get_default_root_window(),
    279         gdk_atom_intern(property,TRUE),
    280         GDK_NONE,
    281         0,
    282         512,
    283         FALSE,
    284         actual_property_type,
    285         actual_format,
    286         actual_length,
    287         data);
     268    result = gdk_property_get(gdk_get_default_root_window(),
     269                              gdk_atom_intern(property, TRUE),
     270                              GDK_NONE,
     271                              0,
     272                              512,
     273                              FALSE,
     274                              actual_property_type,
     275                              actual_format, actual_length, data);
    288276    return result;
    289277}
     
    299287    g_strstrip(buf->str);
    300288
    301     log_entry("gtkgreet",7,"Got command: %s",buf->str);
     289    log_entry("gtkgreet", 7, "Got command: %s", buf->str);
    302290
    303291    if (!g_ascii_strncasecmp(buf->str, "msg", 3)) {
     
    320308    } else if (!g_ascii_strncasecmp(buf->str, "userid", 6)) {
    321309        timeout_enabled = login_timeout > 0;
    322         if(timeout_enabled) {
     310        if (timeout_enabled) {
    323311            gtk_widget_show(timeoutbox);
    324312        }
     
    369357
    370358        // choice;choice 1|choice 2|choice 3
    371         gchar** choices = g_strsplit(buf->str+7, "|", -1);
     359        gchar **choices = g_strsplit(buf->str + 7, "|", -1);
    372360
    373361        // drop combo box to drop model
    374362        gtk_list_store_clear(choiceList);
    375363
    376         for (i=0; i<g_strv_length(choices); ++i) {
     364        for (i = 0; i < g_strv_length(choices); ++i) {
    377365            gtk_list_store_append(GTK_LIST_STORE(choiceList), &iter);
    378366            gtk_list_store_set(GTK_LIST_STORE(choiceList), &iter, 0,
     
    392380
    393381        // pref choice;key;title;menu;icon;choice 1|choice 2|choice 3
    394         gchar** args = g_strsplit(buf->str, ";", 6);
    395         gchar** choices = g_strsplit(args[5], "|", -1);
     382        gchar **args = g_strsplit(buf->str, ";", 6);
     383        gchar **choices = g_strsplit(args[5], "|", -1);
    396384
    397385        GreeterPref *pref = greeter_pref_new(g_strdup(args[1]));
     
    401389        pref->icon = g_strdup(args[4]);
    402390
    403         for (i=0; i<g_strv_length(choices); ++i) {
    404             pref->choices = g_list_append(pref->choices, g_strdup(choices[i]));
     391        for (i = 0; i < g_strv_length(choices); ++i) {
     392            pref->choices =
     393                g_list_append(pref->choices, g_strdup(choices[i]));
    405394        }
    406395
     
    415404        buf->str[buf->len] = '\0';
    416405
    417         valstr = g_strdup_printf("%s\n", greeter_pref_get_value(name).str_val);
     406        valstr =
     407            g_strdup_printf("%s\n", greeter_pref_get_value(name).str_val);
    418408        g_io_channel_write_chars(g_stdout, valstr, -1, NULL, NULL);
    419409        g_io_channel_flush(g_stdout, NULL);
    420410        g_free(valstr);
    421411    } else if (!g_ascii_strncasecmp(buf->str, "allowguest", 10)) {
    422         gchar* valstr = buf->str + 11;
     412        gchar *valstr = buf->str + 11;
    423413        allowguest = g_ascii_strncasecmp(valstr, "false", 2);
    424414        if (!allowguest)
     
    455445handle_choice(GtkComboBox * combo, GdkWindow * window)
    456446{
    457     gchar* selection;
    458     gchar* entrystr;
     447    gchar *selection;
     448    gchar *entrystr;
    459449
    460450    selection = gtk_combo_box_get_active_text(GTK_COMBO_BOX(choiceCombo));
     
    474464    g_io_channel_flush(g_stdout, NULL);
    475465    g_free(entrystr);
    476     if(gtk_entry_get_visibility(GTK_ENTRY(entry)))
     466    if (gtk_entry_get_visibility(GTK_ENTRY(entry)))
    477467        gtk_entry_set_text(entry, "");
    478468}
    479469
    480470static gboolean
    481 menu_append_pref(gpointer akey, gpointer avalue, gpointer adata) {
    482     char* key = (char*)akey;
    483     GreeterPref* pref = (GreeterPref*)avalue;
    484     GtkWidget* menu = (GtkWidget*)adata;
     471menu_append_pref(gpointer akey, gpointer avalue, gpointer adata)
     472{
     473    char *key = (char *) akey;
     474    GreeterPref *pref = (GreeterPref *) avalue;
     475    GtkWidget *menu = (GtkWidget *) adata;
    485476    GtkWidget *pref_item, *prefico;
    486477
    487     pref_item =
    488         gtk_image_menu_item_new_with_mnemonic(_(pref->menu));
     478    pref_item = gtk_image_menu_item_new_with_mnemonic(_(pref->menu));
    489479    prefico = gtk_image_new_from_file(ldm_theme_file(pref->icon));
    490480    gtk_image_menu_item_set_image((GtkImageMenuItem *) pref_item, prefico);
     
    511501    if (getenv("LDM_FORCE_LANGUAGE") == NULL) {
    512502        lang_item =
    513             gtk_image_menu_item_new_with_mnemonic(_("Select _Language ..."));
     503            gtk_image_menu_item_new_with_mnemonic(_
     504                                                  ("Select _Language ..."));
    514505        langico = gtk_image_new_from_file(ldm_theme_file("language"));
    515         gtk_image_menu_item_set_image((GtkImageMenuItem *) lang_item, langico);
     506        gtk_image_menu_item_set_image((GtkImageMenuItem *) lang_item,
     507                                      langico);
    516508        g_signal_connect_swapped(G_OBJECT(lang_item), "activate",
    517509                                 G_CALLBACK(langwin), window);
     
    521513    if (getenv("LDM_FORCE_SESSION") == NULL) {
    522514        sess_item =
    523             gtk_image_menu_item_new_with_mnemonic(_("Select _Session ..."));
     515            gtk_image_menu_item_new_with_mnemonic(_
     516                                                  ("Select _Session ..."));
    524517        sessico = gtk_image_new_from_file(ldm_theme_file("session"));
    525         gtk_image_menu_item_set_image((GtkImageMenuItem *) sess_item, sessico);
     518        gtk_image_menu_item_set_image((GtkImageMenuItem *) sess_item,
     519                                      sessico);
    526520        g_signal_connect_swapped(G_OBJECT(sess_item), "activate",
    527521                                 G_CALLBACK(sesswin), window);
     
    533527            gtk_image_menu_item_new_with_mnemonic(_("Select _Host ..."));
    534528        hostico = gtk_image_new_from_file(ldm_theme_file("host"));
    535         gtk_image_menu_item_set_image((GtkImageMenuItem *) host_item, hostico);
     529        gtk_image_menu_item_set_image((GtkImageMenuItem *) host_item,
     530                                      hostico);
    536531        g_signal_connect_swapped(G_OBJECT(host_item), "activate",
    537532                                 G_CALLBACK(hostwin), window);
     
    539534    }
    540535
    541     for (i=0; i<=9; i++) {
     536    for (i = 0; i <= 9; i++) {
    542537        g_sprintf(custom_env_var, "LDM_MENU_ITEM_%d", i);
    543         custom_mnemonic=getenv(custom_env_var);
     538        custom_mnemonic = getenv(custom_env_var);
    544539        if (custom_mnemonic == NULL)
    545540            continue;
     
    547542            gtk_image_menu_item_new_with_mnemonic(custom_mnemonic);
    548543        g_sprintf(custom_env_var, "LDM_MENU_COMMAND_%d", i);
    549         custom_command=getenv(custom_env_var);
     544        custom_command = getenv(custom_env_var);
    550545        if (custom_command == NULL) {
    551546            gtk_widget_destroy(custom_item);
     
    554549        customico = gtk_image_new_from_file(ldm_theme_file("backend"));
    555550        gtk_image_menu_item_set_image((GtkImageMenuItem *) custom_item,
    556             customico);
     551                                      customico);
    557552        g_signal_connect(G_OBJECT(custom_item), "activate",
    558                          G_CALLBACK(spawn_command), g_strdup(custom_command));
     553                         G_CALLBACK(spawn_command),
     554                         g_strdup(custom_command));
    559555        gtk_menu_shell_append(GTK_MENU_SHELL(menu), custom_item);
    560556    }
     
    603599    else {
    604600        strncpy(dest, source, MAXSTRSZ - 1);
    605         *(dest + MAXSTRSZ - 1) = '\0';     /* ensure null termination */
     601        *(dest + MAXSTRSZ - 1) = '\0';           /* ensure null termination */
    606602    }
    607603
     
    614610 */
    615611static gboolean
    616 key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer window)
     612key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer window)
    617613{
    618614    if ((event->keyval == GDK_Tab ||
    619615         event->keyval == GDK_KP_Tab) &&
    620         (event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SHIFT_MASK)) == 0) {
    621             handle_entry(GTK_ENTRY(entry), window);
    622             return TRUE;
     616        (event->
     617         state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) ==
     618        0) {
     619        handle_entry(GTK_ENTRY(entry), window);
     620        return TRUE;
    623621    }
    624622
     
    629627main(int argc, char *argv[])
    630628{
    631     gint lw;
     629    gint lw, lh;
    632630
    633631    GtkWidget *loginWindow, *prefBar;
     
    643641    gint width, height;
    644642    GIOChannel *g_stdin;
    645     char * ldm_theme;
     643    char *ldm_theme;
    646644
    647645#ifdef ENABLE_NLS
    648     setlocale (LC_ALL, "");
    649     bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
    650     bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    651     textdomain (GETTEXT_PACKAGE);
     646    setlocale(LC_ALL, "");
     647    bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
     648    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
     649    textdomain(GETTEXT_PACKAGE);
    652650#endif
    653651
    654652    /* Init log settings */
    655     log_init(ldm_getenv_bool("LDM_SYSLOG"),ldm_getenv_int("LDM_LOGLEVEL",-1));
     653    log_init(ldm_getenv_bool("LDM_SYSLOG"),
     654             ldm_getenv_int("LDM_LOGLEVEL", -1));
    656655
    657656    gtk_init(&argc, &argv);
    658657    ldm_theme = getenv("LDM_THEME");
    659658
    660     if (ldm_theme)
    661     {
    662         if(*ldm_theme == '/')
     659    if (ldm_theme) {
     660        if (*ldm_theme == '/')
    663661            ldm_theme_dir = g_strdup(ldm_theme);
    664662        else
    665663            ldm_theme_dir = g_strconcat(LDM_THEME_DIR, ldm_theme, NULL);
    666     }
    667     else
    668     {
     664    } else {
    669665        ldm_theme_dir = g_strconcat(LDM_THEME_DIR, "default", NULL);
    670666    }
     
    687683    /* Set the background */
    688684    load_root_background(ldm_theme_file("bg"), TRUE, FALSE);
    689     set_root_background();
    690 
    691     gdk_drawable_get_size(root, &width, &height);
     685
     686    get_default_display_size(&width, &height);
    692687
    693688    /* Setup the time and system labels */
     
    698693#ifdef K12LINUX
    699694        hoststring =
    700             g_strdup_printf("<b>%s</b> (%s)", get_sysname(), getenv("LDMINFO_IPADDR"));
     695            g_strdup_printf("<b>%s</b> (%s)", get_sysname(),
     696                            getenv("LDMINFO_IPADDR"));
    701697#else
    702698        hoststring =
    703             g_strdup_printf("<b>%s</b> (%s) //", get_sysname(), getenv("LDMINFO_IPADDR"));
     699            g_strdup_printf("<b>%s</b> (%s) -", get_sysname(),
     700                            getenv("LDMINFO_IPADDR"));
    704701#endif
    705702        gtk_label_set_markup((GtkLabel *) syslabel, hoststring);
     
    728725
    729726    /**** Create the login window ****/
    730     gtk_window_set_position(GTK_WINDOW(loginWindow), GTK_WIN_POS_CENTER_ALWAYS);
    731727    {
    732         GtkWidget *guestbox, *guestspacer1, *guestspacer2, *vbox, *vbox2, *hbox;
     728        GtkWidget *guestbox, *guestspacer1, *guestspacer2, *vbox, *vbox2,
     729            *vbox2spacer, *hbox;
    733730        GtkCellRenderer *renderer;
    734731
    735         g_signal_connect(G_OBJECT(loginWindow), "destroy", G_CALLBACK(destroy),
    736                          NULL);
     732        g_signal_connect(G_OBJECT(loginWindow), "destroy",
     733                         G_CALLBACK(destroy), NULL);
    737734
    738735        gtk_widget_set_app_paintable(loginWindow, TRUE);
    739736        g_signal_connect(loginWindow, "configure-event",
    740                         G_CALLBACK(draw_background), NULL);
    741         //gtk_widget_set_size_request(loginWindow, width/2, height/2);
    742         //gtk_widget_realize(loginWindow);
    743         gtk_window_set_decorated(GTK_WINDOW (loginWindow), FALSE);
     737                         G_CALLBACK(draw_background), NULL);
     738        gtk_widget_set_size_request(loginWindow, width, height);
     739        gtk_widget_realize(loginWindow);
     740        gtk_window_set_decorated(GTK_WINDOW(loginWindow), FALSE);
    744741
    745742        logo = gtk_image_new_from_file(ldm_theme_file("logo"));
    746743#ifdef K12LINUX
    747         if(access(ldm_theme_file("bottom_right"), R_OK) == 0) {
    748             bottom_right = gtk_image_new_from_file(ldm_theme_file("bottom_right"));
    749             has_bottom_right_image=TRUE;
    750         }
    751         else
    752             has_bottom_right_image=FALSE;
     744        if (access(ldm_theme_file("bottom_right"), R_OK) == 0) {
     745            bottom_right =
     746                gtk_image_new_from_file(ldm_theme_file("bottom_right"));
     747            has_bottom_right_image = TRUE;
     748        } else
     749            has_bottom_right_image = FALSE;
    753750#endif
    754751
    755752        pix = gtk_image_get_pixbuf((GtkImage *) logo);
    756753        lw = gdk_pixbuf_get_width(pix);
     754        lh = gdk_pixbuf_get_height(pix);
    757755
    758756
    759757        vbox = gtk_vbox_new(FALSE, 5);
    760         vbox2 = gtk_vbox_new(FALSE, 0);
     758        vbox2 = gtk_vbox_new(FALSE, ((height / 2) - lh));
     759        vbox2spacer = gtk_vbox_new(FALSE, 5);
    761760        EntryBox = gtk_hbox_new(FALSE, 5);
    762761        hbox = gtk_hbox_new(FALSE, 0);
     
    772771        StatusMessages = gtk_label_new("");
    773772        entry = gtk_entry_new();
    774         gtk_entry_set_width_chars(GTK_ENTRY(entry), 12);
     773        gtk_entry_set_width_chars(GTK_ENTRY(entry), 20);
    775774        g_signal_connect(G_OBJECT(entry), "activate",
    776775                         G_CALLBACK(handle_entry), root);
     
    780779
    781780        choiceList = gtk_list_store_new(1, G_TYPE_STRING);
    782         choiceCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(choiceList));
     781        choiceCombo =
     782            gtk_combo_box_new_with_model(GTK_TREE_MODEL(choiceList));
    783783        renderer = gtk_cell_renderer_text_new();
    784784        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(choiceCombo),
    785                                                    GTK_CELL_RENDERER(renderer),
    786                                                    TRUE);
     785                                   GTK_CELL_RENDERER(renderer), TRUE);
    787786        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(choiceCombo),
    788787                                      GTK_CELL_RENDERER(renderer),
     
    791790                         G_CALLBACK(handle_choice), root);
    792791
    793         if (getenv("LDM_LOGIN_TIMEOUT") != NULL ) {
     792        if (getenv("LDM_LOGIN_TIMEOUT") != NULL) {
    794793            login_timeout = atoi(getenv("LDM_LOGIN_TIMEOUT"));
    795794        } else {
     
    803802        timeoutbox = gtk_hbox_new(FALSE, 0);
    804803        gtk_box_pack_start(GTK_BOX(vbox), timeoutbox, FALSE, FALSE, 0);
    805         gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer1, TRUE, FALSE, 0);
    806         gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutlabel, FALSE, FALSE, 0);
    807         gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer2, TRUE, FALSE, 0);
     804        gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer1, TRUE,
     805                           FALSE, 0);
     806        gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutlabel, FALSE, FALSE,
     807                           0);
     808        gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer2, TRUE,
     809                           FALSE, 0);
    808810        g_timeout_add(1000, (GSourceFunc) update_timeout, timeoutlabel);
    809811
    810812        guestspacer1 = gtk_label_new("");
    811813        guestspacer2 = gtk_label_new("");
    812         GuestButton = gtk_button_new_with_label (_("Login as Guest"));
     814        GuestButton = gtk_button_new_with_label(_("Login as Guest"));
    813815        g_signal_connect(G_OBJECT(GuestButton), "clicked",
    814             G_CALLBACK(handle_guestbutton), root);
    815         gtk_button_set_focus_on_click((GtkButton *)GuestButton, FALSE);
     816                         G_CALLBACK(handle_guestbutton), root);
     817        gtk_button_set_focus_on_click((GtkButton *) GuestButton, FALSE);
    816818        guestbox = gtk_hbox_new(FALSE, 0);
    817         gtk_box_pack_start(GTK_BOX(guestbox), guestspacer1, TRUE, FALSE, 0);
    818         gtk_box_pack_start(GTK_BOX(guestbox), GuestButton, FALSE, FALSE, 0);
    819         gtk_box_pack_start(GTK_BOX(guestbox), guestspacer2, TRUE, FALSE, 0);
     819        gtk_box_pack_start(GTK_BOX(guestbox), guestspacer1, TRUE, FALSE,
     820                           0);
     821        gtk_box_pack_start(GTK_BOX(guestbox), GuestButton, FALSE, FALSE,
     822                           0);
     823        gtk_box_pack_start(GTK_BOX(guestbox), guestspacer2, TRUE, FALSE,
     824                           0);
    820825
    821826        entryspacer1 = gtk_label_new("");
    822827        entryspacer2 = gtk_label_new("");
    823         gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer1, TRUE, FALSE, 0);
     828        gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer1, TRUE, FALSE,
     829                           0);
    824830        gtk_box_pack_start(GTK_BOX(EntryBox), UserPrompt, FALSE, FALSE, 0);
    825831        gtk_box_pack_start(GTK_BOX(EntryBox), entry, FALSE, FALSE, 0);
    826         gtk_box_pack_start(GTK_BOX(EntryBox), choiceCombo, FALSE, FALSE, 0);
    827         gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer2, TRUE, FALSE, 0);
     832        gtk_box_pack_start(GTK_BOX(EntryBox), choiceCombo, FALSE, FALSE,
     833                           0);
     834        gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer2, TRUE, FALSE,
     835                           0);
    828836
    829837        gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 5);
    830838        gtk_box_pack_start(GTK_BOX(vbox), EntryBox, TRUE, FALSE, 0);
    831         if(allowguest) gtk_box_pack_start(GTK_BOX(vbox), guestbox, FALSE, FALSE, 0);
     839        if (allowguest)
     840            gtk_box_pack_start(GTK_BOX(vbox), guestbox, FALSE, FALSE, 0);
    832841        gtk_box_pack_start(GTK_BOX(vbox), timeoutbox, FALSE, FALSE, 0);
    833842        gtk_box_pack_start(GTK_BOX(vbox), StatusMessages, TRUE, FALSE, 0);
    834843        gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, FALSE, 0);
     844        gtk_box_pack_start(GTK_BOX(vbox2), vbox2spacer, FALSE, FALSE, 0);
    835845        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0);
    836846
     
    843853        GtkWidget *BottomBarBox;
    844854
    845         gtk_widget_set_app_paintable(GTK_WIDGET (prefBar), TRUE);
     855        gtk_widget_set_app_paintable(GTK_WIDGET(prefBar), TRUE);
    846856        g_signal_connect(prefBar, "configure-event",
    847                         G_CALLBACK(draw_background), NULL);
    848         gtk_window_set_decorated(GTK_WINDOW (prefBar), FALSE);
     857                         G_CALLBACK(draw_background), NULL);
     858        gtk_window_set_decorated(GTK_WINDOW(prefBar), FALSE);
    849859        gtk_widget_set_size_request(prefBar, width, BOTTOM_BAR_HEIGHT);
    850860
     
    862872        optionbutton_box = gtk_vbox_new(FALSE, 0);
    863873        optionbutton_spacer = gtk_label_new("");
    864         gtk_box_pack_start(GTK_BOX(optionbutton_box), GTK_WIDGET(optionbutton_spacer), TRUE, FALSE, 0);
    865         gtk_box_pack_end(GTK_BOX(optionbutton_box), GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
     874        gtk_box_pack_start(GTK_BOX(optionbutton_box),
     875                           GTK_WIDGET(optionbutton_spacer), TRUE, FALSE,
     876                           0);
     877        gtk_box_pack_end(GTK_BOX(optionbutton_box),
     878                         GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
    866879        gtk_box_pack_start(GTK_BOX(BottomBarBox),
    867880                           GTK_WIDGET(optionbutton_box), FALSE, FALSE, 5);
    868881
    869         if(has_bottom_right_image == TRUE) {
     882        if (has_bottom_right_image == TRUE) {
    870883            bottom_right_box = gtk_vbox_new(FALSE, 0);
    871884            bottom_right_spacer = gtk_label_new("");
    872             gtk_box_pack_start(GTK_BOX(bottom_right_box), GTK_WIDGET(bottom_right_spacer), TRUE, FALSE, 0);
    873             gtk_box_pack_end(GTK_BOX(bottom_right_box), GTK_WIDGET(bottom_right), FALSE, FALSE, 0);
     885            gtk_box_pack_start(GTK_BOX(bottom_right_box),
     886                               GTK_WIDGET(bottom_right_spacer), TRUE,
     887                               FALSE, 0);
     888            gtk_box_pack_end(GTK_BOX(bottom_right_box),
     889                             GTK_WIDGET(bottom_right), FALSE, FALSE, 0);
    874890            gtk_box_pack_end(GTK_BOX(BottomBarBox),
    875                              GTK_WIDGET(bottom_right_box), FALSE, FALSE, 0);
     891                             GTK_WIDGET(bottom_right_box), FALSE, FALSE,
     892                             0);
    876893        }
    877894#endif
    878         gtk_container_add(GTK_CONTAINER (prefBar), BottomBarBox);
     895        gtk_container_add(GTK_CONTAINER(prefBar), BottomBarBox);
    879896    }
    880897
     
    885902        GtkWidget *TopBarBox;
    886903
    887         gtk_window_set_decorated(GTK_WINDOW (topBar), FALSE);
     904        gtk_window_set_decorated(GTK_WINDOW(topBar), FALSE);
    888905        gtk_widget_set_size_request(topBar, width, TOP_BAR_HEIGHT);
    889906
    890907        TopBarBox = gtk_hbox_new(FALSE, 5);
    891908        gtk_box_pack_start(GTK_BOX(TopBarBox),
    892                          GTK_WIDGET(syslabel), FALSE, FALSE, 5);
     909                           GTK_WIDGET(syslabel), FALSE, FALSE, 5);
    893910        gtk_box_pack_end(GTK_BOX(TopBarBox),
    894911                         GTK_WIDGET(timelabel), FALSE, FALSE, 5);
     
    899916    gtk_widget_show_all(loginWindow);
    900917    gtk_widget_show_all(prefBar);
    901     gtk_window_move(GTK_WINDOW (prefBar), 0, height - BOTTOM_BAR_HEIGHT);
     918    gtk_window_move(GTK_WINDOW(loginWindow), 0, 0);
     919    gtk_window_move(GTK_WINDOW(prefBar), 0, height - BOTTOM_BAR_HEIGHT);
    902920#ifdef K12LINUX
    903921    gtk_widget_show_all(topBar);
    904     gtk_window_move(GTK_WINDOW (topBar), 0, 0);
     922    gtk_window_move(GTK_WINDOW(topBar), 0, 0);
    905923#endif
    906924
     925    // Center the mouse pointer on the default display
     926    GdkDisplay *display = gdk_display_get_default();
     927    GdkScreen *screen = gdk_display_get_default_screen(display);
     928    GdkRectangle bbox;
     929    gdk_screen_get_monitor_geometry(screen, 0, &bbox);
     930    gdk_display_warp_pointer(display, screen, bbox.width/2, bbox.height/2);
    907931    gdk_window_set_cursor(root, normcursor);
    908932
  • ldm/trunk/fuentes/gtkgreet/langwin.c

    r516 r855  
    7070
    7171        curr_host =
    72             ldminfo_lookup(g_list_nth_data(host_list,
    73                   selected_host_id));
     72            ldminfo_lookup(g_list_nth_data(host_list, selected_host_id));
    7473        l = curr_host->languages;
    7574        g_strlcpy(language, g_list_nth_data(l, lang_selected - 1),
     
    9998     */
    10099
    101     curr_host = ldminfo_lookup(g_list_nth_data(host_list, selected_host_id));
     100    curr_host =
     101        ldminfo_lookup(g_list_nth_data(host_list, selected_host_id));
    102102
    103103    gtk_combo_box_append_text(GTK_COMBO_BOX(lang_select),
     
    136136    label = gtk_label_new("");
    137137    gtk_label_set_markup((GtkLabel *) label,
    138                          _("Select the language for your session to use:"));
     138                         _
     139                         ("Select the language for your session to use:"));
    139140
    140141    gtk_box_pack_start((GtkBox *) vbox, (GtkWidget *) label, FALSE, FALSE,
  • ldm/trunk/fuentes/gtkgreet/prefs.c

    r516 r855  
    2626#include <sys/socket.h>
    2727
    28 static GTree* greeter_prefs = NULL;
     28static GTree *greeter_prefs = NULL;
    2929
    30 static int g_strcmp(gconstpointer a, gconstpointer b) {
    31     return strcmp((char*)a, (char*)b);
     30static int
     31g_strcmp(gconstpointer a, gconstpointer b)
     32{
     33    return strcmp((char *) a, (char *) b);
    3234}
    3335
    34 void greeter_pref_init() {
     36void
     37greeter_pref_init()
     38{
    3539    if (greeter_prefs) {
    3640        g_tree_destroy(greeter_prefs);
     
    4044}
    4145
    42 GreeterPref* greeter_pref_new(const gchar* name) {
    43     GreeterPref* pref = g_malloc0(sizeof(GreeterPref));
     46GreeterPref *
     47greeter_pref_new(const gchar * name)
     48{
     49    GreeterPref *pref = g_malloc0(sizeof(GreeterPref));
    4450    g_tree_replace(greeter_prefs, g_strdup(name), pref);
    4551    pref->choices = g_list_alloc();
     
    4854}
    4955
    50 void greeter_pref_destroy(const gchar* name) {
     56void
     57greeter_pref_destroy(const gchar * name)
     58{
    5159    gpointer key;
    5260    gpointer valptr;
    53     GreeterPref* value;
     61    GreeterPref *value;
    5462
    5563    g_tree_lookup_extended(greeter_prefs, name, &key, &valptr);
    56     value = (GreeterPref*)valptr;
     64    value = (GreeterPref *) valptr;
    5765    if (value->choices) {
    58         g_list_foreach(value->choices, (GFunc)g_free, NULL);
     66        g_list_foreach(value->choices, (GFunc) g_free, NULL);
    5967        g_list_free(value->choices);
    6068    }
     
    7482}
    7583
    76 void greeter_pref_prompt(const gchar* name) {
     84void
     85greeter_pref_prompt(const gchar * name)
     86{
    7787}
    7888
    79 GreeterPref* greeter_pref_get_pref(const gchar* name) {
    80     return (GreeterPref*)g_tree_lookup(greeter_prefs, name);
     89GreeterPref *
     90greeter_pref_get_pref(const gchar * name)
     91{
     92    return (GreeterPref *) g_tree_lookup(greeter_prefs, name);
    8193}
    8294
    83 PrefValue greeter_pref_get_value(const gchar* name) {
    84     GreeterPref* value = (GreeterPref*) g_tree_lookup(greeter_prefs, name);
     95PrefValue
     96greeter_pref_get_value(const gchar * name)
     97{
     98    GreeterPref *value =
     99        (GreeterPref *) g_tree_lookup(greeter_prefs, name);
    85100    if (!value) {
    86         return (PrefValue)"None";
    87     } if (value->value.int_val == 0) {
    88         return (PrefValue)"None";
     101        return (PrefValue) "None";
     102    }
     103    if (value->value.int_val == 0) {
     104        return (PrefValue) "None";
    89105    }
    90106
    91     return (PrefValue)(char*)g_list_nth_data(value->choices,
    92                                              value->value.int_val);
     107    return (PrefValue) (char *) g_list_nth_data(value->choices,
     108                                                value->value.int_val);
    93109}
    94110
    95 void greeter_pref_foreach(GTraverseFunc func, gpointer user_data) {
     111void
     112greeter_pref_foreach(GTraverseFunc func, gpointer user_data)
     113{
    96114    g_tree_foreach(greeter_prefs, func, user_data);
    97115}
    98 
  • ldm/trunk/fuentes/gtkgreet/prefwin.c

    r516 r855  
    2828#include "greeter.h"
    2929
    30 static GtkWidget* pref_combo = NULL;
     30static GtkWidget *pref_combo = NULL;
    3131static gint choice_total = 0;
    3232
     
    3434
    3535typedef struct {
    36     GtkWidget* prefwin;
    37     const gchar* prefname;
     36    GtkWidget *prefwin;
     37    const gchar *prefname;
    3838} PrefData;
    3939
     
    4343
    4444static void
    45 prefwin_accept(GtkWidget * widget, PrefData* data)
     45prefwin_accept(GtkWidget * widget, PrefData * data)
    4646{
    47     GreeterPref* pref = greeter_pref_get_pref(data->prefname);
    48     gchar* notif;
     47    GreeterPref *pref = greeter_pref_get_pref(data->prefname);
     48    gchar *notif;
    4949
    50     pref->value.int_val = gtk_combo_box_get_active(GTK_COMBO_BOX(pref_combo));
     50    pref->value.int_val =
     51        gtk_combo_box_get_active(GTK_COMBO_BOX(pref_combo));
    5152    gtk_widget_destroy(data->prefwin);
    5253
     
    7576{
    7677
    77     GreeterPref* pref;
     78    GreeterPref *pref;
    7879    GtkWidget *prefwin, *label, *vbox, *buttonbox;
    7980    GtkWidget *cancel, *accept, *frame;
     
    9192                   (GFunc) populate_pref_combo_box, pref_combo);
    9293
    93     gtk_combo_box_set_active(GTK_COMBO_BOX(pref_combo), pref->value.int_val);
     94    gtk_combo_box_set_active(GTK_COMBO_BOX(pref_combo),
     95                             pref->value.int_val);
    9496
    9597    /*
     
    111113
    112114    accept = gtk_button_new_from_stock("gtk-ok");
    113     PrefData* data = g_malloc0(sizeof(PrefData));
     115    PrefData *data = g_malloc0(sizeof(PrefData));
    114116    data->prefwin = prefwin;
    115117    data->prefname = pref_name;
     
    123125
    124126    label = gtk_label_new("");
    125     gtk_label_set_markup((GtkLabel *) label,
    126                          _(pref->title));
     127    gtk_label_set_markup((GtkLabel *) label, _(pref->title));
    127128
    128129    gtk_box_pack_start((GtkBox *) vbox, (GtkWidget *) label, FALSE, FALSE,
     
    144145    return;
    145146}
    146 
  • ldm/trunk/fuentes/gtkgreet/sesswin.c

    r516 r855  
    6868        GList *s = NULL;
    6969
    70         curr_host = ldminfo_lookup(g_list_nth_data(host_list, selected_host_id));
     70        curr_host =
     71            ldminfo_lookup(g_list_nth_data(host_list, selected_host_id));
    7172        s = curr_host->sessions;
    7273        g_strlcpy(session, g_list_nth_data(s, sess_selected - 2),
     
    100101     */
    101102
    102     curr_host = ldminfo_lookup(g_list_nth_data(host_list, current_host_id));
     103    curr_host =
     104        ldminfo_lookup(g_list_nth_data(host_list, current_host_id));
    103105
    104106    gtk_combo_box_append_text(GTK_COMBO_BOX(sess_select),
  • ldm/trunk/fuentes/misc/ldm-dialog.c

    r516 r855  
    4646int auto_close;
    4747
    48 void yes_clicked(GtkWidget * widget, GtkWidget * mywin)
     48void
     49yes_clicked(GtkWidget * widget, GtkWidget * mywin)
    4950{
    5051    gtk_main_quit();
     
    5253}
    5354
    54 void no_clicked(GtkWidget * widget, GtkWidget * mywin)
     55void
     56no_clicked(GtkWidget * widget, GtkWidget * mywin)
    5557{
    5658    gtk_main_quit();
     
    5860}
    5961
    60 void link_clicked(GtkWidget * widget, GtkLabel * mywin)
    61 {
    62     printf("url: %s\n",gtk_label_get_current_uri(GTK_LABEL(widget)));
     62void
     63link_clicked(GtkWidget * widget, GtkLabel * mywin)
     64{
     65    printf("url: %s\n", gtk_label_get_current_uri(GTK_LABEL(widget)));
    6366    gtk_main_quit();
    6467    exit(0);
    6568}
    6669
    67 void update_progressbar()
    68 {
    69     gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), current_number/100.0);
    70     if(current_number < 100.0) {
    71         if(yes)
     70void
     71update_progressbar()
     72{
     73    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress),
     74                                  current_number / 100.0);
     75    if (current_number < 100.0) {
     76        if (yes)
    7277            gtk_widget_set_sensitive(yes, FALSE);
    7378    } else {
    74         if(auto_close == TRUE)
     79        if (auto_close == TRUE)
    7580            yes_clicked(NULL, NULL);
    76         if(yes) {
     81        if (yes) {
    7782            gtk_widget_set_sensitive(yes, TRUE);
    7883            gtk_widget_grab_focus(yes);
     
    8186}
    8287
    83 void update_progressbar_from_channel(GIOChannel * channel)
     88void
     89update_progressbar_from_channel(GIOChannel * channel)
    8490{
    8591    GString *buf;
     
    9298}
    9399
    94 void usage(char * progname) {
    95     printf("Usage: %s --message|--question|--progress [mode specific options] \"message\"\n", progname);
     100void
     101usage(char *progname)
     102{
     103    printf
     104        ("Usage: %s --message|--question|--progress [mode specific options] \"message\"\n",
     105         progname);
    96106    printf("Progress mode options: --auto-close\n");
    97107    exit(1);
     
    100110#define USAGE() usage(argv[0])
    101111
    102 int main(int argc, char ** argv){
    103     GtkWidget *mywin, *vbox, *hbox, *label, *spacer, *big_hbox, *ospacer, *o2spacer;
     112int
     113main(int argc, char **argv)
     114{
     115    GtkWidget *mywin, *vbox, *hbox, *label, *spacer, *big_hbox, *ospacer,
     116        *o2spacer;
    104117    int mode;
    105118    int retval;
    106     char * message;
     119    char *message;
    107120    int has_no_button, has_yes_button;
    108121    mode = NOTHING;
     
    111124    auto_close = FALSE;
    112125
    113     setlocale (LC_ALL, "");
    114     bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
    115     bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    116     textdomain (GETTEXT_PACKAGE);
     126    setlocale(LC_ALL, "");
     127    bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
     128    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
     129    textdomain(GETTEXT_PACKAGE);
    117130
    118131    // Option processing
     
    122135        {"progress", 0, 0, PROGRESS},
    123136        {"auto-close", 0, 0, AUTO_CLOSE_OPTION},
    124         {0,0,0,0}
     137        {0, 0, 0, 0}
    125138    };
    126     while(1) {
     139    while (1) {
    127140        retval = getopt_long(argc, argv, "", longopts, NULL);
    128         if(retval == -1)
    129             break;
    130         switch(retval) {
     141        if (retval == -1)
     142            break;
     143        switch (retval) {
    131144        case MESSAGE:
    132145        case QUESTION:
    133146        case PROGRESS:
    134             if(mode != NOTHING)
     147            if (mode != NOTHING)
    135148                USAGE();
    136149            mode = retval;
     
    144157        }
    145158    }
    146     if(mode == NOTHING)
     159    if (mode == NOTHING)
    147160        USAGE();
    148     if((argc - optind) != 1)
     161    if ((argc - optind) != 1)
    149162        USAGE();
    150     if(auto_close == TRUE && mode != PROGRESS)
     163    if (auto_close == TRUE && mode != PROGRESS)
    151164        USAGE();
    152165    message = argv[optind];
    153     switch(mode) {
     166    switch (mode) {
    154167    case MESSAGE:
    155168        has_no_button = FALSE;
     
    158171        break;
    159172    case PROGRESS:
    160         if(auto_close == TRUE)
     173        if (auto_close == TRUE)
    161174            has_yes_button = FALSE;
    162175        break;
     
    167180
    168181    // Theme
    169     char * ldm_theme;
    170     gchar * ldm_gtkrc;
     182    char *ldm_theme;
     183    gchar *ldm_gtkrc;
    171184    ldm_theme = getenv("LDM_THEME");
    172     if (ldm_theme)
    173     {
    174         if(*ldm_theme == '/')
     185    if (ldm_theme) {
     186        if (*ldm_theme == '/')
    175187            ldm_gtkrc = g_strconcat(ldm_theme, "/greeter-gtkrc", NULL);
    176188        else
    177             ldm_gtkrc = g_strconcat(LDM_THEME_DIR, ldm_theme, "/greeter-gtkrc", NULL);
     189            ldm_gtkrc =
     190                g_strconcat(LDM_THEME_DIR, ldm_theme, "/greeter-gtkrc",
     191                            NULL);
    178192    } else
    179         ldm_gtkrc = g_strconcat(LDM_THEME_DIR, "default", "/greeter-gtkrc", NULL);
     193        ldm_gtkrc =
     194            g_strconcat(LDM_THEME_DIR, "default", "/greeter-gtkrc", NULL);
    180195    gtk_rc_add_default_file(ldm_gtkrc);
    181196    g_free(ldm_gtkrc);
    182197    // Finish setting up the basic stuff
    183198    mywin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    184     gdk_window_set_cursor(gdk_get_default_root_window(), gdk_cursor_new(GDK_LEFT_PTR));
    185     gtk_window_set_title(GTK_WINDOW(mywin),"");
    186     gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mywin),TRUE);
    187     gtk_window_set_resizable (GTK_WINDOW(mywin),0);
     199    gdk_window_set_cursor(gdk_get_default_root_window(),
     200                          gdk_cursor_new(GDK_LEFT_PTR));
     201    gtk_window_set_title(GTK_WINDOW(mywin), "");
     202    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mywin), TRUE);
     203    gtk_window_set_resizable(GTK_WINDOW(mywin), 0);
    188204    gtk_window_set_position(GTK_WINDOW(mywin), GTK_WIN_POS_CENTER_ALWAYS);
    189     g_signal_connect(GTK_WINDOW(mywin), "destroy", G_CALLBACK(no_clicked), mywin);
     205    g_signal_connect(GTK_WINDOW(mywin), "destroy", G_CALLBACK(no_clicked),
     206                     mywin);
    190207    hbox = gtk_hbox_new(FALSE, 3);
    191208    spacer = gtk_label_new("");
     
    197214
    198215    // Make the yes button
    199     if(has_yes_button == TRUE) {
     216    if (has_yes_button == TRUE) {
    200217        yes = gtk_button_new_from_stock("gtk-ok");
    201         g_signal_connect(G_OBJECT(yes), "clicked", G_CALLBACK(yes_clicked), mywin);
     218        g_signal_connect(G_OBJECT(yes), "clicked", G_CALLBACK(yes_clicked),
     219                         mywin);
    202220        gtk_box_pack_start(GTK_BOX(hbox), yes, FALSE, FALSE, 0);
    203221    }
    204 
    205222    // Make the no button
    206     if(has_no_button == TRUE) {
     223    if (has_no_button == TRUE) {
    207224        no = gtk_button_new_from_stock("gtk-cancel");
    208         g_signal_connect(G_OBJECT(no), "clicked", G_CALLBACK(no_clicked), mywin);
     225        g_signal_connect(G_OBJECT(no), "clicked", G_CALLBACK(no_clicked),
     226                         mywin);
    209227        gtk_box_pack_start(GTK_BOX(hbox), no, FALSE, FALSE, 0);
    210228    }
    211 
    212229    // Create the label
    213230    label = gtk_label_new(message);
     
    215232    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    216233    gtk_window_set_default_size(GTK_WINDOW(mywin), 300, -1);
    217     g_signal_connect(GTK_LABEL(label), "activate-link", G_CALLBACK(link_clicked), label);
     234    g_signal_connect(GTK_LABEL(label), "activate-link",
     235                     G_CALLBACK(link_clicked), label);
    218236
    219237    vbox = gtk_vbox_new(FALSE, 0);
    220     GtkWidget * blah;
     238    GtkWidget *blah;
    221239    blah = gtk_alignment_new(0, 0.5, 0, 0);
    222240    gtk_container_add(GTK_CONTAINER(blah), label);
    223241    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(blah), FALSE, FALSE, 10);
    224242
    225     if(mode == PROGRESS) {
     243    if (mode == PROGRESS) {
    226244        // Make the progress bar
    227245        progress = gtk_progress_bar_new();
     
    235253        // Set up the hook that listens for input
    236254        g_stdin = g_io_channel_unix_new(0);
    237         g_io_add_watch(g_stdin, G_IO_IN, (GIOFunc) update_progressbar_from_channel, g_stdin);
    238     }
    239 
     255        g_io_add_watch(g_stdin, G_IO_IN,
     256                       (GIOFunc) update_progressbar_from_channel, g_stdin);
     257    }
    240258    // More basic GTK stuff
    241259    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
  • ldm/trunk/fuentes/po/POTFILES.in

    r516 r855  
    1111gtkgreet/langwin.c
    1212gtkgreet/prefwin.c
    13 rc.d/I01-halt-check
    1413rc.d/I01-nbd-checkupdate
    1514rc.d/S15-userLoginCheck
  • ldm/trunk/fuentes/rc.d/Makefile.am

    r516 r855  
    11EXTRA_DIST = $(rcd_DATA)
    22rcddir = $(datadir)/ldm/rc.d
    3 rcd_DATA = I01-halt-check I01-nbd-checkupdate K99-ltsp-cluster P00-ltsp-cluster S01-setup-xauth S15-userLoginCheck S20-restrictUser S99-debug-terminal S99-ltsp-cluster X50-generate-env X50-dmrc-processing X50-printers X51-opengl X52-xcompmgr X95-run-x-session
     3rcd_DATA = I01-nbd-checkupdate K99-ltsp-cluster P00-ltsp-cluster S01-setup-xauth S15-userLoginCheck S20-restrictUser S99-debug-terminal S99-ltsp-cluster X50-generate-env X50-dmrc-processing X50-printers X52-xcompmgr X95-run-x-session
  • ldm/trunk/fuentes/rc.d/X50-dmrc-processing

    r516 r855  
    1818
    1919# for code readability
     20do_command(){
     21    if boolean_is_true "$LTSP_FATCLIENT" ; then
     22       eval "$@"
     23    else
     24       do_ssh "$@"
     25    fi
     26}
     27
    2028do_ssh(){
    2129    ssh -S "$LDM_SOCKET" "$LDM_SERVER" "$@" 2>/dev/null
     
    3341
    3442    if [ -n "$desktop" ]; then
    35         session_exec=$(do_ssh sed -n "s/^Exec=//p" "/usr/share/xsessions/$desktop.desktop")
     43        session_exec=$(do_command sed -n "s/^Exec=//p" "/usr/share/xsessions/$desktop.desktop")
    3644        if [ -n "$session_exec" ]; then
    3745            LDM_SESSION="$session_exec"
     
    6371            ;;
    6472        default|'')
    65             ldm_session_from_desktop_file "$(get_dmrc_key "Session")" && break
    66             ldm_session_from_desktop_file "$LDM_SESSION" && break
     73            ldm_session_from_desktop_file "$(get_dmrc_key "Session")" ||
     74                ldm_session_from_desktop_file "$LDM_SESSION" ||
     75                true
    6776            ;;
    6877        *)
    6978            LDM_SESSION="$LDM_SELECTED_SESSION"
    7079            # If there's a corresponding xsession.desktop file, save its name to .dmrc
    71             dmrc_session=$(do_ssh "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")
     80            dmrc_session=$(do_command "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")
    7281            if [ -n "$dmrc_session" ]; then
    7382                put_dmrc_key "Session" "$dmrc_session"
  • ldm/trunk/fuentes/rc.d/X50-generate-env

    r516 r855  
    11# -*- Shell-Script -*-
    22
    3 # Set up the LTSP_CLIENT and LTSP_CLIENT_HOSTNAME environment variables.
    4 # We may not want to force set this:
     3# Set up the LTSP_* environment variables.
     4CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT=$LDMINFO_IPADDR LTSP_CLIENT_HOSTNAME=$(hostname)"
     5test -n "$LTSP_CLIENT_MAC" && CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT_MAC=$LTSP_CLIENT_MAC"
     6if boolean_is_true "$LTSP_FATCLIENT"; then
     7    CLIENT_ENV="$CLIENT_ENV LTSP_FATCLIENT=$LTSP_FATCLIENT"
     8fi
    59
    6 CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT=$LDMINFO_IPADDR LTSP_CLIENT_HOSTNAME=$(hostname)"
    7 test -n "$LTSP_FATCLIENT" && CLIENT_ENV="$CLIENT_ENV LTSP_FATCLIENT=$LTSP_FATCLIENT"
    8 test -n "$LTSP_CLIENT_MAC" && CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT_MAC=$LTSP_CLIENT_MAC"
     10# Some DEs *require* certain environment variables to be set by the DM,
     11# notably DESKTOP_SESSION and XDG_CURRENT_DESKTOP. Let's try to set them here.
     12# At this point, LDM_SESSION is either unset,
     13# or it's set to the Exec= line of an xsession.desktop file,
     14# or it's user-defined, in which case we don't need to set any vars.
     15# do_command() was defined in X50-dmrc-processing.
     16if [ -z "$LDM_SESSION" ]; then
     17    default_session=$(basename "$(do_command "readlink -qs /etc/alternatives/x-session-manager")")
     18    # If default_session is empty, we select the first one with an Exec= line
     19    DESKTOP_SESSION=$(do_command "grep -lR '^Exec=$default_session' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")
     20else
     21    DESKTOP_SESSION=$(do_command "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")
     22fi
     23if [ -n "$DESKTOP_SESSION" ]; then
     24    # We're setting the default LDM_SESSION instead of leaving it empty,
     25    # only as a workaround for LP #1457730.
     26    LDM_SESSION=$(do_command "sed -n 's/^Exec=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'")
     27    # Match the deprecated X-LightDM-DesktopName and the newer DesktopNames.
     28    XDG_CURRENT_DESKTOP=$(do_command "sed -n 's/^[^=]*DesktopName[^=]*=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'")
     29    if [ -z "$XDG_CURRENT_DESKTOP" ]; then
     30        XDG_CURRENT_DESKTOP=$(do_command "sed -n 's/^Name=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'")
     31    fi
     32    # DesktopNames is separated by ";" while XDG_CURRENT_DESKTOP by ":".
     33    XDG_CURRENT_DESKTOP=$(echo "${XDG_CURRENT_DESKTOP%;}" | tr ';' ':')
     34fi
     35test -n "$DESKTOP_SESSION" && CLIENT_ENV="$CLIENT_ENV DESKTOP_SESSION='$DESKTOP_SESSION'"
     36test -n "$XDG_CURRENT_DESKTOP" && CLIENT_ENV="$CLIENT_ENV XDG_CURRENT_DESKTOP='$XDG_CURRENT_DESKTOP'"
     37
    938export CLIENT_ENV
     39
    1040# Set our language, if a different one is picked.
    11 
    12 if [ -z "$LDM_LANGUAGE" ]; then
    13     LDM_LANGUAGE=$LANG
     41if [ -n "$LDM_LANGUAGE" ]; then
     42    MY_LANG="LANG=$LDM_LANGUAGE"
     43    export MY_LANG
    1444fi
    1545
     
    1949
    2050# Set the DISPLAY env, if not running over encrypted ssh
    21 
    2251if boolean_is_true "$LDM_DIRECTX"; then
    2352    MY_DISP="DISPLAY=${LDMINFO_IPADDR}${DISPLAY}"
     
    3665
    3766# Handle sound
    38 
    3967if boolean_is_true "$SOUND"; then
    4068    if [ -z "$SOUND_DAEMON" ]; then
  • ldm/trunk/fuentes/screen.d/ldm

    r516 r855  
    128128fi
    129129
    130 if [ -x /usr/share/ltsp/xinitrc ]; then
    131     xinitrc=/usr/share/ltsp/xinitrc
     130if boolean_is_true "$LDM_DIRECTX" ; then
     131    if [ $({ echo "1.17"; X -version 2>&1 | sed -n 's/X.Org X Server //p';} | sort -V | head -n 1) = "1.17" ]; then
     132        # Xorg after 1.17 needs `-listen tcp`, see
     133        # http://cgit.freedesktop.org/xorg/xserver/commit/?id=cc59be38b7eff52a1d003b390f2994c73ee0b3e9
     134        X_ARGS="-listen tcp $X_ARGS"
     135    fi
     136else
     137    X_ARGS="-nolisten tcp $X_ARGS"
    132138fi
     139
     140xinitrc=/usr/share/ltsp/xinitrc
    133141
    134142
  • ldm/trunk/fuentes/share/ldm-script.in

    r516 r855  
    5050
    5151for SCRIPT in $(find -L $RCDIRS -type f -name "$SCRIPTS" -printf '%f\n' |
    52     tr ' ' '\n' | egrep ^[0-9a-zA-Z_\-]*$ | sort -u)
     52    tr ' ' '\n' | egrep ^[[:alnum:]_\-]*$ | sort -u)
    5353do
    5454    # only source the first instance of the script found
  • ldm/trunk/fuentes/src/ldm.c

    r516 r855  
    4747 *  Setting up LDM env. variables
    4848 */
    49 void get_ldm_env() {
     49void
     50get_ldm_env()
     51{
    5052    gchar *greeter_path, *wm_path;
    5153
     
    6769        greeter_path = g_strdup("ldmgtkgreet");
    6870
    69     if(greeter_path[0] != '/') {
    70         ldm.greeter_prog = g_strjoin("/", LDM_EXEC_DIR, greeter_path, NULL);
     71    if (greeter_path[0] != '/') {
     72        ldm.greeter_prog =
     73            g_strjoin("/", LDM_EXEC_DIR, greeter_path, NULL);
    7174        g_free(greeter_path);
    7275    } else {
     
    7578
    7679    wm_path = g_strdup(getenv("LDM_WINMANAGER"));
    77     if(!wm_path)
     80    if (!wm_path)
    7881        wm_path = g_strdup("wwm");
    7982
    80     if(wm_path[0] != '/') {
     83    if (wm_path[0] != '/') {
    8184        ldm.wm_prog = g_strjoin("/", LDM_EXEC_DIR, wm_path, NULL);
    8285        g_free(wm_path);
     
    9093 * main entry point
    9194 */
    92 int main(int argc, char *argv[]) {
     95int
     96main(int argc, char *argv[])
     97{
    9398    /* decls */
    9499    gchar *auth_plugin = NULL;
     
    96101
    97102    /* Init log settings */
    98     log_init(ldm_getenv_bool("LDM_SYSLOG"),ldm_getenv_int("LDM_LOGLEVEL",-1));
     103    log_init(ldm_getenv_bool("LDM_SYSLOG"),
     104             ldm_getenv_int("LDM_LOGLEVEL", -1));
    99105
    100106#ifdef ENABLE_NLS
    101     setlocale (LC_ALL, "");
    102     bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
    103     bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    104     textdomain (GETTEXT_PACKAGE);
     107    setlocale(LC_ALL, "");
     108    bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
     109    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
     110    textdomain(GETTEXT_PACKAGE);
    105111#endif
    106112
     
    111117    sigemptyset(&action.sa_mask);
    112118    action.sa_flags = SA_SIGINFO;
    113     sigaction (SIGCHLD, &action, NULL);
     119    sigaction(SIGCHLD, &action, NULL);
    114120
    115121    /*
     
    118124    bzero(&ldm, sizeof ldm);
    119125
    120     ldm.pid = getpid();  /* Get our pid, to use in the command_socket */
     126    ldm.pid = getpid();                          /* Get our pid, to use in the command_socket */
    121127    ldm.display = g_strdup(getenv("DISPLAY"));
    122128
     
    125131     */
    126132    get_ipaddr();
    127     log_entry("ldm",6,"started on client with IP address: %s", ldm.ipaddr);
     133    log_entry("ldm", 6, "started on client with IP address: %s",
     134              ldm.ipaddr);
    128135
    129136    /*
     
    140147     * Load plugins
    141148     */
    142     if(ldm_load_plugins())
    143         log_entry("ldm",3,"unable to load plugins");
     149    if (ldm_load_plugins())
     150        log_entry("ldm", 3, "unable to load plugins");
    144151
    145152    /*
    146153     * Begin running display manager
    147154     */
    148     log_entry("ldm",6,"calling rc.d init scripts");
    149     rc_files("init");                      /* Execute any rc files */
     155    log_entry("ldm", 6, "calling rc.d init scripts");
     156    rc_files("init");                            /* Execute any rc files */
    150157
    151158    if (!ldm.autologin) {
     
    153160        gint rfd, wfd, rfd2, wfd2;
    154161
    155         log_entry("ldm",7,"spawning window manager: %s", ldm.wm_prog);
     162        log_entry("ldm", 7, "spawning window manager: %s", ldm.wm_prog);
    156163        ldm.wmpid = ldm_spawn(ldm.wm_prog, &rfd2, &wfd2, NULL);
    157         log_entry("ldm",7,"spawning greeter: %s", ldm.greeter_prog);
     164        log_entry("ldm", 7, "spawning greeter: %s", ldm.greeter_prog);
    158165        ldm.greeterpid = ldm_spawn(ldm.greeter_prog, &rfd, &wfd, NULL);
    159166        set_greeter_pid(ldm.greeterpid);
     
    171178            /* allow choosing backend */
    172179            backends = g_strjoinv("|", ldm_get_plugins());
    173             cmd = g_strconcat("pref choice;backend;Authentication Backend;Select _Backend ...;session;",
    174                               backends, "\n", NULL);
    175             if(ask_greeter(cmd))
     180            cmd =
     181                g_strconcat
     182                ("pref choice;backend;Authentication Backend;Select _Backend ...;session;",
     183                 backends, "\n", NULL);
     184            if (ask_greeter(cmd))
    176185                die("ldm", "%s from greeter failed", cmd);
    177186            g_free(backends);
     
    196205            /* Init plugin */
    197206            set_current_plugin(auth_plugin);
    198             log_entry("ldm",6,"authenticating with backend: %s", auth_plugin);
     207            log_entry("ldm", 6, "authenticating with backend: %s",
     208                      auth_plugin);
    199209            ldm_setup_plugin();
    200210        } while (ldm_auth_plugin());
     
    205215
    206216        set_current_plugin(auth_plugin);
    207         log_entry("ldm",6,"guest authenticating with backend: %s", auth_plugin);
     217        log_entry("ldm", 6, "guest authenticating with backend: %s",
     218                  auth_plugin);
    208219        ldm_setup_plugin();
    209220
     
    222233     */
    223234
    224     log_entry("ldm",6,"X session ended");
    225 
    226     log_entry("ldm",6,"calling rc.d stop scripts");
    227     rc_files("stop");                       /* Execute any rc files */
     235    log_entry("ldm", 6, "X session ended");
     236
     237    log_entry("ldm", 6, "calling rc.d stop scripts");
     238    rc_files("stop");                            /* Execute any rc files */
    228239
    229240    /* Closing plugin */
     
    245256    g_free(ldm.control_socket);
    246257    g_free(ldm.ipaddr);
    247     g_list_foreach(host_list, (GFunc)g_free, NULL);
     258    g_list_foreach(host_list, (GFunc) g_free, NULL);
    248259    g_list_free(host_list);
    249260
  • ldm/trunk/fuentes/src/ldmgreetercomm.c

    r516 r855  
    2020 * set_greeter_pid
    2121 */
    22 void set_greeter_pid(GPid p) {
     22void
     23set_greeter_pid(GPid p)
     24{
    2325    greeterpid = p;
    2426}
     
    2729 * set_greeter_read_channel
    2830 */
    29 void set_greeter_read_channel(GIOChannel *gr) {
     31void
     32set_greeter_read_channel(GIOChannel * gr)
     33{
    3034    greeterr = gr;
    3135}
     
    3438 * set_greeter_read_channel
    3539 */
    36 void set_greeter_write_channel(GIOChannel *gw) {
     40void
     41set_greeter_write_channel(GIOChannel * gw)
     42{
    3743    greeterw = gw;
    3844}
     
    4551 *  Return 1 if fails, else 0
    4652 */
    47 int ask_greeter(gchar *cmd) {
     53int
     54ask_greeter(gchar * cmd)
     55{
    4856    /* Write command to io channel of the greeter */
    4957    GError *ge = NULL;
    50     if(g_io_channel_write_chars(greeterw, cmd, -1, NULL, &ge) != G_IO_STATUS_NORMAL) {
    51         log_entry("ldm",4,"%s", ge->message);
     58    if (g_io_channel_write_chars(greeterw, cmd, -1, NULL, &ge) !=
     59        G_IO_STATUS_NORMAL) {
     60        log_entry("ldm", 4, "%s", ge->message);
    5261        return 1;
    5362    }
    5463
    5564    /* Flush buffer */
    56     if(g_io_channel_flush(greeterw, &ge) != G_IO_STATUS_NORMAL) {
    57         log_entry("ldm",4,"%s", ge->message);
     65    if (g_io_channel_flush(greeterw, &ge) != G_IO_STATUS_NORMAL) {
     66        log_entry("ldm", 4, "%s", ge->message);
    5867        return 1;
    5968    }
     
    6776 *      s_ldm -- struct ldm_info
    6877 */
    69 void close_greeter() {
     78void
     79close_greeter()
     80{
    7081    gboolean failed = 0;
    7182    gchar *cmd = "quit\n";
     
    7485        return;
    7586
    76     if(ask_greeter(cmd))
     87    if (ask_greeter(cmd))
    7788        failed = 1;
    7889
    79     if(failed) {
    80         log_entry("ldm",3,"quit command failed. SIGTERM to greeter");
    81         if(kill(greeterpid, SIGTERM) < 0) {
    82             log_entry("ldm",3,"SIGTERM failed. SIGKILL to greeter");
     90    if (failed) {
     91        log_entry("ldm", 3, "quit command failed. SIGTERM to greeter");
     92        if (kill(greeterpid, SIGTERM) < 0) {
     93            log_entry("ldm", 3, "SIGTERM failed. SIGKILL to greeter");
    8394            kill(greeterpid, SIGKILL);
    8495        }
     
    97108 *  Ask greeter to print a message to UI
    98109 */
    99 int set_message(gchar *msg) {
     110int
     111set_message(gchar * msg)
     112{
    100113    gchar *cmd;
    101114
     
    104117
    105118    cmd = g_strconcat("msg ", msg, "\n", NULL);
    106     if(ask_greeter(cmd))
     119    if (ask_greeter(cmd))
    107120        return 1;
    108121    g_free(cmd);
     
    120133 *  Return 1 if fails, else 0 and buffer with data in
    121134 */
    122 int listen_greeter(gchar **buffer, gsize *buflen, gsize *end) {
     135int
     136listen_greeter(gchar ** buffer, gsize * buflen, gsize * end)
     137{
    123138    while (1) {
    124139        /* Reads data from I/O channel of the greeter */
    125140        GError *ge = NULL;
    126         if(g_io_channel_read_line(greeterr, buffer, buflen, end, &ge) != G_IO_STATUS_NORMAL) {
    127             log_entry("ldm",3,"%s", ge->message);
     141        if (g_io_channel_read_line(greeterr, buffer, buflen, end, &ge) !=
     142            G_IO_STATUS_NORMAL) {
     143            log_entry("ldm", 3, "%s", ge->message);
    128144            return 1;
    129145        }
    130146
    131147        g_strstrip(*buffer);
    132         log_entry("ldm",7,"Got command: %s",*buffer);
     148        log_entry("ldm", 7, "Got command: %s", *buffer);
    133149
    134150        /* handle callbacks */
     
    154170 *      buffer -- buffer to write to answer
    155171 */
    156 gchar *ask_value_greeter(gchar *cmd) {
     172gchar *
     173ask_value_greeter(gchar * cmd)
     174{
    157175    gsize len, end;
    158176    gchar *buffer;
    159     if(ask_greeter(cmd))
     177    if (ask_greeter(cmd))
    160178        die("ldm", "%s from greeter failed", cmd);
    161179
    162     if(listen_greeter(&buffer, &len, &end))
     180    if (listen_greeter(&buffer, &len, &end))
    163181        die("ldm", "%s from greeter failed", cmd);
    164182
  • ldm/trunk/fuentes/src/ldminfo.c

    r516 r855  
    4040static GHashTable *ldminfo_hash = NULL;
    4141
    42 static void generate_hash_table(void) {
     42static void
     43generate_hash_table(void)
     44{
    4345    char buffer[1024];
    44     FILE * file;
    45     char ** ret;
    46     display_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
     46    FILE *file;
     47    char **ret;
     48    display_names =
     49        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    4750    file = fopen(RC_DIR "/locales", "r");
    48     if(file == NULL) {
     51    if (file == NULL) {
    4952        return;
    5053    }
    51     while(fgets(buffer, sizeof(buffer), file) != NULL) {
     54    while (fgets(buffer, sizeof(buffer), file) != NULL) {
    5255        ret = g_strsplit(buffer, " ", 2);
    53         g_hash_table_insert(display_names, g_strdup(ret[0]), g_strdup(g_strchomp(ret[1])));
     56        g_hash_table_insert(display_names, g_strdup(ret[0]),
     57                            g_strdup(g_strchomp(ret[1])));
    5458        g_strfreev(ret);
    5559    }
     
    5761}
    5862
    59 static gchar * get_display_name(gchar * locale) {
    60     gchar * compare_to;
    61     char ** ret;
    62     gchar * result;
     63static gchar *
     64get_display_name(gchar * locale)
     65{
     66    gchar *compare_to;
     67    char **ret;
     68    gchar *result;
    6369    ret = g_strsplit(locale, ".", 2);
    6470    compare_to = g_strdup(ret[0]);
    6571    g_strfreev(ret);
    66     if(compare_to == NULL) {
     72    if (compare_to == NULL) {
    6773        return g_strdup(locale);
    6874    }
    6975    result = g_hash_table_lookup(display_names, compare_to);
    70     if(result == NULL) {
     76    if (result == NULL) {
    7177        result = g_strdup(locale);
    7278    }
     
    7884 *  ldminfo struct freed
    7985 */
    80 void ldminfo_free() {
     86void
     87ldminfo_free()
     88{
    8189    g_hash_table_destroy(ldminfo_hash);
    8290}
     
    8593 * ldminfo_lookup
    8694 */
    87 ldminfo *ldminfo_lookup(gconstpointer key) {
     95ldminfo *
     96ldminfo_lookup(gconstpointer key)
     97{
    8898    return g_hash_table_lookup(ldminfo_hash, key);
    8999}
     
    92102 * ldminfo_size
    93103 */
    94 int ldminfo_size() {
     104int
     105ldminfo_size()
     106{
    95107    return g_hash_table_size(ldminfo_hash);
    96108}
     
    99111 * ldminfo_init
    100112 */
    101 void ldminfo_init(GList **host_list, const char *ldm_server) {
     113void
     114ldminfo_init(GList ** host_list, const char *ldm_server)
     115{
    102116    char **hosts_char = NULL;
    103117    ldminfo *ldm_host_info = NULL;
     
    108122    /* Static hash table */
    109123    ldminfo_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
    110                                           g_free, g_free);
     124                                         g_free, g_free);
    111125    hosts_char = g_strsplit(ldm_server, " ", -1);
    112126
     
    152166 * etc. Things like nc -z hostname ssh, etc.
    153167 */
    154 void _ldminfo_query_one(const char *hostname, ldminfo * ldm_host_info) {
     168void
     169_ldminfo_query_one(const char *hostname, ldminfo * ldm_host_info)
     170{
    155171    int filedes, numbytes;
    156172    char buf[MAXBUFSIZE];
     
    181197 * split string by line and then construct the ldm_host_info
    182198 */
    183 void _ldminfo_parse_string(const char *s, ldminfo * ldm_host_info) {
     199void
     200_ldminfo_parse_string(const char *s, ldminfo * ldm_host_info)
     201{
    184202    char **lines = NULL;
    185203    int i;
     
    194212                g_list_append(ldm_host_info->languages, g_strdup(val[1]));
    195213            ldm_host_info->language_names =
    196                 g_list_append(ldm_host_info->language_names, get_display_name(val[1]));
    197             g_strfreev(val);
    198         } else if (!g_ascii_strncasecmp(lines[i], "session:", 8) && !g_strstr_len(s, -1, "session-with-name")) {
     214                g_list_append(ldm_host_info->language_names,
     215                              get_display_name(val[1]));
     216            g_strfreev(val);
     217        } else if (!g_ascii_strncasecmp(lines[i], "session:", 8)
     218                   && !g_strstr_len(s, -1, "session-with-name")) {
    199219            gchar **val;
    200220            gchar *name;
    201221            val = g_strsplit(lines[i], ":", 2);
    202222            name = g_strrstr(val[1], "/");
    203             if(name) {
     223            if (name) {
    204224                name++;
    205225            } else {
    206226                name = val[1];
    207227            }
    208             ldm_host_info->sessions = g_list_append(ldm_host_info->sessions, g_strdup(val[1]));
    209             ldm_host_info->session_names = g_list_append(ldm_host_info->session_names, g_strdup(name));
     228            ldm_host_info->sessions =
     229                g_list_append(ldm_host_info->sessions, g_strdup(val[1]));
     230            ldm_host_info->session_names =
     231                g_list_append(ldm_host_info->session_names,
     232                              g_strdup(name));
    210233            g_strfreev(val);
    211234        } else if (!g_ascii_strncasecmp(lines[i], "session-with-name:", 8)) {
    212235            gchar **val;
    213236            val = g_strsplit(lines[i], ":", 3);
    214             ldm_host_info->sessions = g_list_append(ldm_host_info->sessions, g_strdup(val[2]));
    215             ldm_host_info->session_names = g_list_append(ldm_host_info->session_names, g_strdup(val[1]));
     237            ldm_host_info->sessions =
     238                g_list_append(ldm_host_info->sessions, g_strdup(val[2]));
     239            ldm_host_info->session_names =
     240                g_list_append(ldm_host_info->session_names,
     241                              g_strdup(val[1]));
    216242            g_strfreev(val);
    217243        } else if (!g_ascii_strncasecmp(lines[i], "rating:", 7)) {
     
    238264 *      name -- env. variable name
    239265 */
    240 int ldm_getenv_bool(const char *name) {
     266int
     267ldm_getenv_bool(const char *name)
     268{
    241269    char *env = getenv(name);
    242270
    243     if(env) {
     271    if (env) {
    244272        if (*env == 'y' || *env == 't' || *env == 'T' || *env == 'Y')
    245273            return 1;
     
    249277
    250278/*
     279 * ldm_getenv_bool_default
     280 *  Return if env variable is set to true or false
     281 *      name -- env. variable name
     282 *      default_value -- int to return as default [0,1]
     283 */
     284int
     285ldm_getenv_bool_default(const char *name, const int default_value)
     286{
     287    char *env = getenv(name);
     288
     289    if (env != NULL) {
     290        if (*env == 'y' || *env == 't' || *env == 'T' || *env == 'Y') {
     291            return 1;
     292        } else {
     293            return 0;
     294        }
     295    }   
     296    return default_value;
     297}
     298
     299/*
    251300 * ldm_getenv_int
    252301 *  Return an int, will return default_value if not set
    253302 */
    254 int ldm_getenv_int(const char *name,int default_value) {
     303int
     304ldm_getenv_int(const char *name, int default_value)
     305{
    255306    char *env = getenv(name);
    256307
    257     if(env) {
     308    if (env) {
    258309        return atoi(env);
    259310    }
    260311    return default_value;
    261312}
     313
     314/*
     315 * ldm_getenv_str_default
     316 *  Return a string, will return default_value if not set
     317 *  No malloc()s, caller should strdup the result if needed.
     318 */
     319const char *
     320ldm_getenv_str_default(const char *name, const char *default_value)
     321{
     322    char *env = getenv(name);
     323
     324    if (env) {
     325        return env;
     326    }
     327    return default_value;
     328}
  • ldm/trunk/fuentes/src/ldminfo.h

    r516 r855  
    4646
    4747int ldm_getenv_bool(const char *name);
     48int ldm_getenv_bool_default(const char *name, const int default_value);
    4849int ldm_getenv_int(const char *name, int default_value);
     50const char *ldm_getenv_str_default(const char *name, const char *default_value);
    4951
    5052ldminfo *ldminfo_lookup(gconstpointer key);
  • ldm/trunk/fuentes/src/ldmplugin.c

    r516 r855  
    1313#include "logging.h"
    1414
    15 GTree* plugin_list = NULL;
    16 gchar** plugin_names = NULL;
     15GTree *plugin_list = NULL;
     16gchar **plugin_names = NULL;
    1717static jmp_buf auth_jmp_buf;
    18 static gchar* current_plugin = NULL;
    19 
    20 static int g_strcmp(gconstpointer a, gconstpointer b) {
    21     return strcmp((char*)a, (char*)b);
     18static gchar *current_plugin = NULL;
     19
     20static int
     21g_strcmp(gconstpointer a, gconstpointer b)
     22{
     23    return strcmp((char *) a, (char *) b);
    2224}
    2325
     
    2628 *  Set current plugin name
    2729 */
    28 void set_current_plugin(char *plug_name) {
     30void
     31set_current_plugin(char *plug_name)
     32{
    2933    current_plugin = plug_name;
    3034}
     
    3438 *  Iterate over plugin_list and start plugin
    3539 */
    36 void ldm_start_plugin() {
    37     LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin);
    38     if(desc->start_cb)
     40void
     41ldm_start_plugin()
     42{
     43    LdmBackend *desc =
     44        (LdmBackend *) g_tree_lookup(plugin_list, current_plugin);
     45    if (desc->start_cb)
    3946        desc->start_cb();
    4047}
     
    4451 *  Iterate over plugin_list and close plugin
    4552 */
    46 void ldm_close_plugin() {
    47     LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin);
    48     if(desc->clean_cb)
     53void
     54ldm_close_plugin()
     55{
     56    LdmBackend *desc =
     57        (LdmBackend *) g_tree_lookup(plugin_list, current_plugin);
     58    if (desc->clean_cb)
    4959        desc->clean_cb();
    5060}
     
    5464 *  Call setup callback function of plugin
    5565 */
    56 void ldm_setup_plugin() {
    57     log_entry("ldm",7,"setting up plugin: %s", current_plugin);
    58     LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin);
    59     if(desc->init_cb)
     66void
     67ldm_setup_plugin()
     68{
     69    log_entry("ldm", 7, "setting up plugin: %s", current_plugin);
     70    LdmBackend *desc =
     71        (LdmBackend *) g_tree_lookup(plugin_list, current_plugin);
     72    if (desc->init_cb)
    6073        desc->init_cb();
    6174}
     
    6578 *  Call setup guest authentication values of plugin
    6679 */
    67 void ldm_guest_auth_plugin() {
    68     log_entry("ldm",7,"guest auth plugin: %s", current_plugin);
    69     LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin);
    70     if(desc->guest_cb)
     80void
     81ldm_guest_auth_plugin()
     82{
     83    log_entry("ldm", 7, "guest auth plugin: %s", current_plugin);
     84    LdmBackend *desc =
     85        (LdmBackend *) g_tree_lookup(plugin_list, current_plugin);
     86    if (desc->guest_cb)
    7187        desc->guest_cb();
    7288}
     
    7793 *  Returns 0 on success, 1 otherwise
    7894 */
    79 int ldm_auth_plugin() {
    80     LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin);
     95int
     96ldm_auth_plugin()
     97{
     98    LdmBackend *desc =
     99        (LdmBackend *) g_tree_lookup(plugin_list, current_plugin);
    81100
    82101    if (desc->guest_cb)
     
    86105
    87106    switch (setjmp(auth_jmp_buf)) {
    88         case AUTH_EXC_NONE:
    89             if(desc->auth_cb)
    90                 desc->auth_cb();
    91             return 0;
    92         case AUTH_EXC_RELOAD_BACKEND:
    93             ldm_close_plugin();
    94 
    95             log_entry("ldm",7,"reloading backend");
    96             return 1;
    97         case AUTH_EXC_GUEST:
    98             if(desc->guest_cb)
    99                 desc->guest_cb();
    100             return 0;
     107    case AUTH_EXC_NONE:
     108        if (desc->auth_cb)
     109            desc->auth_cb();
     110        return 0;
     111    case AUTH_EXC_RELOAD_BACKEND:
     112        ldm_close_plugin();
     113
     114        log_entry("ldm", 7, "reloading backend");
     115        return 1;
     116    case AUTH_EXC_GUEST:
     117        if (desc->guest_cb)
     118            desc->guest_cb();
     119        return 0;
    101120    }
    102121    return 1;
     
    108127 */
    109128void __attribute__ ((visibility("default")))
    110 ldm_init_plugin(LdmBackend* descriptor) {
    111     gchar** new_plugin_names;
     129    ldm_init_plugin(LdmBackend * descriptor)
     130{
     131    gchar **new_plugin_names;
    112132    int plugin_names_len;
    113133
    114134    plugin_names_len = g_strv_length(plugin_names);
    115135    new_plugin_names = g_realloc(plugin_names,
    116                                  (plugin_names_len+1)*sizeof(gchar*));
     136                                 (plugin_names_len + 1) * sizeof(gchar *));
    117137    if (new_plugin_names != plugin_names) {
    118138        g_free(plugin_names);
     
    120140    }
    121141    plugin_names[plugin_names_len] = g_strdup(descriptor->name);
    122     plugin_names[plugin_names_len+1] = NULL;
     142    plugin_names[plugin_names_len + 1] = NULL;
    123143
    124144    g_tree_replace(plugin_list, descriptor->name, descriptor);
    125     log_entry("ldm",7,"%s initialized", descriptor->name);
     145    log_entry("ldm", 7, "%s initialized", descriptor->name);
    126146}
    127147
     
    131151 *      path -- plugin path
    132152 */
    133 void _load_plugin(const char *path) {
     153void
     154_load_plugin(const char *path)
     155{
    134156    void *handle = dlopen(path, RTLD_LAZY);
    135157    if (handle) {
    136         log_entry("ldm",7,"loaded %s", path);
     158        log_entry("ldm", 7, "loaded %s", path);
    137159        return;
    138160    }
    139161
    140     log_entry("ldm",4,"%s: Invalid LDM plugin %s", dlerror(), path);
     162    log_entry("ldm", 4, "%s: Invalid LDM plugin %s", dlerror(), path);
    141163}
    142164
     
    145167 *  Load all plugins at LDM_PLUG_DIR
    146168 */
    147 int ldm_load_plugins() {
     169int
     170ldm_load_plugins()
     171{
    148172    plugin_list = g_tree_new(g_strcmp);
    149173    g_tree_ref(plugin_list);
    150     plugin_names = g_malloc0(sizeof(gchar*));
    151 
    152     DIR* plugin_dir = opendir(LDM_PLUG_DIR);
     174    plugin_names = g_malloc0(sizeof(gchar *));
     175
     176    DIR *plugin_dir = opendir(LDM_PLUG_DIR);
    153177
    154178    if (!plugin_dir) {
    155         log_entry("ldm",3,"unable to open plugin dir: %s", LDM_PLUG_DIR);
     179        log_entry("ldm", 3, "unable to open plugin dir: %s", LDM_PLUG_DIR);
    156180        return 1;
    157181    }
    158     struct dirent* entry;
    159     while ( (entry = readdir(plugin_dir)) ) {
    160         if ((entry->d_type == DT_REG || entry->d_type == DT_UNKNOWN) && (strstr(entry->d_name, ".so") != NULL)) {
    161             int name_len = strlen(entry->d_name)+strlen(LDM_PLUG_DIR)+2;
    162             char* plug_name = (char *) malloc(name_len);
    163             snprintf(plug_name, name_len, "%s/%s", LDM_PLUG_DIR, entry->d_name);
    164             log_entry("ldm",7,"loading: %s", plug_name);
     182    struct dirent *entry;
     183    while ((entry = readdir(plugin_dir))) {
     184        if ((entry->d_type == DT_REG || entry->d_type == DT_UNKNOWN)
     185            && (strstr(entry->d_name, ".so") != NULL)) {
     186            int name_len =
     187                strlen(entry->d_name) + strlen(LDM_PLUG_DIR) + 2;
     188            char *plug_name = (char *) malloc(name_len);
     189            snprintf(plug_name, name_len, "%s/%s", LDM_PLUG_DIR,
     190                     entry->d_name);
     191            log_entry("ldm", 7, "loading: %s", plug_name);
    165192
    166193            _load_plugin(plug_name);
     
    169196    }
    170197
    171     if (errno) perror(strerror(errno));
     198    if (errno)
     199        perror(strerror(errno));
    172200    closedir(plugin_dir);
    173201    return 0;
     
    179207 * error before retrying.
    180208 */
    181 void ldm_raise_auth_except(LdmAuthException n) {
     209void
     210ldm_raise_auth_except(LdmAuthException n)
     211{
    182212    longjmp(auth_jmp_buf, n);
    183213}
    184214
    185 gchar** ldm_get_plugins() {
     215gchar **
     216ldm_get_plugins()
     217{
    186218    return plugin_names;
    187219}
    188 
  • ldm/trunk/fuentes/src/ldmutils.c

    r516 r855  
    2222 * Run startup commands.
    2323 */
    24 void rc_files(char *action) {
     24void
     25rc_files(char *action)
     26{
    2527    GPid rcpid;
    2628    gchar *command;
    2729
    28     command = g_strjoin(" ", "/bin/sh",  RC_DIR "/ldm-script", action, NULL);
     30    command =
     31        g_strjoin(" ", "/bin/sh", RC_DIR "/ldm-script", action, NULL);
    2932
    3033    rcpid = ldm_spawn(command, NULL, NULL, NULL);
     
    3841 *  Get ip address of host
    3942 */
    40 void get_ipaddr() {
     43void
     44get_ipaddr()
     45{
    4146    int numreqs = 10;
    4247    struct ifconf ifc;
    43     struct ifreq *ifr;    /* netdevice(7) */
     48    struct ifreq *ifr;          /* netdevice(7) */
    4449    struct ifreq info;
    4550    struct sockaddr_in *sa;
     
    4954    skfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
    5055    if (skfd < 0)
    51         die("ldm","socket");
     56        die("ldm", "socket");
    5257
    5358    /*
     
    5964    while (TRUE) {
    6065        ifc.ifc_len = sizeof(struct ifreq) * numreqs;
    61         ifc.ifc_buf = (char *)realloc(ifc.ifc_buf, ifc.ifc_len);
     66        ifc.ifc_buf = (char *) realloc(ifc.ifc_buf, ifc.ifc_len);
    6267        if (ifc.ifc_buf == NULL)
    63             die("ldm","out of memory");
     68            die("ldm", "out of memory");
    6469
    6570        if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
    66             log_entry("ldm",4,"SIOCGIFCONF");
     71            log_entry("ldm", 4, "SIOCGIFCONF");
    6772            goto out;
    6873        }
    6974
    70         if (ifc.ifc_len == (int)sizeof(struct ifreq) * numreqs){
     75        if (ifc.ifc_len == (int) sizeof(struct ifreq) * numreqs) {
    7176            /* assume it overflowed and try again */
    7277            numreqs += 10;
     
    8994        strcpy(info.ifr_name, ifr->ifr_name);
    9095        if (ioctl(skfd, SIOCGIFFLAGS, &info) < 0) {
    91             log_entry("ldm",4,"SIOCGIFFLAGS");
     96            log_entry("ldm", 4, "SIOCGIFFLAGS");
    9297            goto out;
    9398        }
     
    102107    }
    103108
    104 out:
     109  out:
    105110    if (ifc.ifc_buf)
    106111        free(ifc.ifc_buf);
    107112
    108113    if (n == ifc.ifc_len)
    109         die("ldm","no configured interface found");
     114        die("ldm", "no configured interface found");
    110115}
    111116
     
    115120 * Execute commands.  Prints nice error message if failure.
    116121 */
    117 GPid ldm_spawn(gchar *command, gint *rfd, gint *wfd,  GSpawnChildSetupFunc setup) {
     122GPid
     123ldm_spawn(gchar * command, gint * rfd, gint * wfd,
     124          GSpawnChildSetupFunc setup)
     125{
    118126    GPid pid;
    119127    GError *error = NULL;
     
    122130    gchar **argv = NULL;
    123131
    124     g_shell_parse_argv (command, &argc, &argv, NULL);
     132    g_shell_parse_argv(command, &argc, &argv, NULL);
    125133
    126134    if (!wfd)
    127135        flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
    128136
    129     g_spawn_async_with_pipes (
    130             NULL,             /* Working directory: inherit */
    131             argv,             /* Arguments, null term */
    132             NULL,             /* Environment, inherit from parent */
    133             flags,            /* Flags, set above */
    134             setup,            /* Child setup function: passed to us */
    135             NULL,             /* No user data */
    136             &pid,             /* child pid */
    137             wfd,              /* Pointer to in file descriptor */
    138             rfd,              /* Pointer to out file descriptor */
    139             NULL,             /* No stderr */
    140             &error);          /* GError handler */
     137    g_spawn_async_with_pipes(NULL,               /* Working directory: inherit */
     138                             argv,               /* Arguments, null term */
     139                             NULL,               /* Environment, inherit from parent */
     140                             flags,              /* Flags, set above */
     141                             setup,              /* Child setup function: passed to us */
     142                             NULL,               /* No user data */
     143                             &pid,               /* child pid */
     144                             wfd,                /* Pointer to in file descriptor */
     145                             rfd,                /* Pointer to out file descriptor */
     146                             NULL,               /* No stderr */
     147                             &error);            /* GError handler */
    141148
    142149    g_strfreev(argv);
    143150
    144151    if (error) {
    145         log_entry("ldm",3,"ldm_spawn failed to execute: %s", error->message);
     152        log_entry("ldm", 3, "ldm_spawn failed to execute: %s",
     153                  error->message);
    146154    } else {
    147         log_entry("ldm",7,"ldm_spawn: pid = %d", pid);
     155        log_entry("ldm", 7, "ldm_spawn: pid = %d", pid);
    148156    }
    149157
     
    158166 * ldm_wait
    159167 */
    160 void handle_sigchld(int signo) {
     168void
     169handle_sigchld(int signo)
     170{
    161171    /* do nothing */
    162172    child_exited = TRUE;
     
    168178 * wait for child process
    169179 */
    170 void ldm_wait(GPid pid) {
     180void
     181ldm_wait(GPid pid)
     182{
    171183    siginfo_t info;
    172     log_entry("ldm",7,"waiting for process: %d", pid);
     184    log_entry("ldm", 7, "waiting for process: %d", pid);
    173185    do {
    174186        int res;
    175         res = waitid (P_PID, pid, &info, WEXITED | WSTOPPED);
     187        res = waitid(P_PID, pid, &info, WEXITED | WSTOPPED);
    176188        if (res == -1) {
    177189            int temp;
    178190            temp = errno;
    179             log_entry("ldm",4,"waitid returned an error: %s", strerror(errno));
    180             if(temp == ECHILD) {
     191            log_entry("ldm", 4, "waitid returned an error: %s",
     192                      strerror(errno));
     193            if (temp == ECHILD) {
    181194                break;
    182195            }
     
    189202                break;
    190203            } else {
    191                 log_entry("ldm",4,"unexpected terminated process, pid: %d",
    192                         info.si_pid);
     204                log_entry("ldm", 4,
     205                          "unexpected terminated process, pid: %d",
     206                          info.si_pid);
    193207                unexpected_child = TRUE;
    194208            }
     
    197211
    198212    if (info.si_code == CLD_EXITED) {
    199         log_entry("ldm",7,"process %d exited with status %d", info.si_pid,
    200                 WEXITSTATUS(info.si_status));
     213        log_entry("ldm", 7, "process %d exited with status %d",
     214                  info.si_pid, WEXITSTATUS(info.si_status));
    201215    } else if (info.si_code == CLD_KILLED) {
    202         log_entry("ldm",7,"process %d killed by signal %d", info.si_pid,
    203                 info.si_status);
     216        log_entry("ldm", 7, "process %d killed by signal %d", info.si_pid,
     217                  info.si_status);
    204218    }
    205219}
     
    209223 *  Close window manager by SIGKILL
    210224 */
    211 void close_wm() {
     225void
     226close_wm()
     227{
    212228    if (!(ldm.wmpid)) {
    213229        return;
    214230    }
    215231
    216     log_entry("ldm",7,"closing window manager");
     232    log_entry("ldm", 7, "closing window manager");
    217233    if (kill(ldm.wmpid, SIGKILL) < 0) {
    218         log_entry("ldm",3,"sending SIGKILL to window manager failed");
     234        log_entry("ldm", 3, "sending SIGKILL to window manager failed");
    219235    }
    220236    ldm_wait(ldm.wmpid);
    221237    ldm.wmpid = 0;
    222238}
    223 
  • ldm/trunk/fuentes/src/logging.c

    r516 r855  
    4646 *  the boolean LDM_SYSLOG.
    4747 */
    48 void log_init(int syslog, int level) {
     48void
     49log_init(int syslog, int level)
     50{
    4951    if (level < 0 || level > 7) {
    5052        loglevel = LOGLEVEL;
    51     }
    52     else {
     53    } else {
    5354        loglevel = level;
    5455    }
     
    5657    if (syslog) {
    5758        openlog("ldm", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
    58     }
    59     else {
     59    } else {
    6060        logfile = fopen(LOGFILE, "a");
    6161        if (!logfile) {
     
    6363            exit(1);
    6464        }
    65         setbuf(logfile, NULL);  /* unbuffered writes to the log file */
     65        setbuf(logfile, NULL);                   /* unbuffered writes to the log file */
    6666    }
    6767}
     
    7171 *  Close logging and clean exit
    7272 */
    73 void log_close() {
     73void
     74log_close()
     75{
    7476    if (logfile)
    7577        fclose(logfile);
     
    8284 * log_entry: log messages to file or syslog
    8385 */
    84 void log_entry(char *component, int level, const char *format, ...) {
     86void
     87log_entry(char *component, int level, const char *format, ...)
     88{
    8589    if (level < 0 || level > 7 || level > loglevel)
    8690        return;
     
    98102        strftime(timestr, sizeof(timestr), "%b %e %H:%M:%S", ptr);
    99103
    100         fprintf(logfile, "%s: [%s] %s: ", timestr, component, LOG_LEVEL_NAMES[level]);
     104        fprintf(logfile, "%s: [%s] %s: ", timestr, component,
     105                LOG_LEVEL_NAMES[level]);
    101106        vfprintf(logfile, format, ap);
    102107        fprintf(logfile, "\n");
     
    114119 *      msg -- log message
    115120 */
    116 void die(char *component, const char *format, ...) {
     121void
     122die(char *component, const char *format, ...)
     123{
    117124    va_list ap;
    118125    va_start(ap, format);
  • ldm/trunk/fuentes/src/plugin.c

    r516 r855  
    1515 *  Ask the greeter to check autologin or get username
    1616 */
    17 void get_userid(gchar **username) {
     17void
     18get_userid(gchar ** username)
     19{
    1820    gchar *cmd;
    1921
     
    2729 * get_passwd
    2830 */
    29 void get_passwd(gchar **password) {
     31void
     32get_passwd(gchar ** password)
     33{
    3034    gchar *cmd;
    3135
    32     cmd = g_strconcat("prompts <b>", _("Password"), "</b>\npasswd\n", NULL);
    33     *password = (gchar*) ask_value_greeter(cmd);
     36    cmd =
     37        g_strconcat("prompts <b>", _("Password"), "</b>\npasswd\n", NULL);
     38    *password = (gchar *) ask_value_greeter(cmd);
    3439
    35     set_message(g_strconcat("<b>", _("Verifying password.  Please wait."), "</b>", NULL));
     40    set_message(g_strconcat
     41                ("<b>", _("Verifying password.  Please wait."), "</b>",
     42                 NULL));
    3643    g_free(cmd);
    3744}
     
    4047 * get_host
    4148 */
    42 void get_host(gchar **server) {
     49void
     50get_host(gchar ** server)
     51{
    4352    gchar *cmd = "hostname\n";
    4453    gchar *host;
    4554
    46     host = (gchar*) ask_value_greeter(cmd);
    47     if(g_ascii_strncasecmp(host, "None", 4)) {
    48         if(*server)
     55    host = (gchar *) ask_value_greeter(cmd);
     56    if (g_ascii_strncasecmp(host, "None", 4)) {
     57        if (*server)
    4958            g_free(*server);
    5059        *server = host;
     
    5564 * get_language
    5665 */
    57 void get_language(gchar **language) {
     66void
     67get_language(gchar ** language)
     68{
    5869    gchar *cmd = "language\n";
    5970    gchar *lang;
    6071
    61     lang = (gchar*) ask_value_greeter(cmd);
     72    lang = (gchar *) ask_value_greeter(cmd);
    6273
    63     if(g_ascii_strncasecmp(lang, "None", 4)) {
    64         if(*language)
     74    if (g_ascii_strncasecmp(lang, "None", 4)) {
     75        if (*language)
    6576            g_free(*language);
    6677        *language = lang;
     
    7283 * get_session
    7384 */
    74 void get_session(gchar **session) {
     85void
     86get_session(gchar ** session)
     87{
    7588    gchar *cmd = "session\n";
    7689    gchar *sess;
    7790
    78     sess = (gchar*) ask_value_greeter(cmd);
     91    sess = (gchar *) ask_value_greeter(cmd);
    7992
    8093    if (g_ascii_strncasecmp(sess, "None", 4)) {
     
    90103 * Return to variable xsession the LDM_XSESSION info
    91104 */
    92 void __attribute__ ((visibility("default"))) get_Xsession(gchar **xsession, gconstpointer server) {
     105void __attribute__ ((visibility("default"))) get_Xsession(gchar **
     106                                                          xsession,
     107                                                          gconstpointer
     108                                                          server)
     109{
    93110    ldminfo *curr_host = NULL;
    94111    gchar *tmp_xsess = NULL;
     
    97114    if (!tmp_xsess || strlen(tmp_xsess) == 0) {
    98115        curr_host = ldminfo_lookup(server);
    99         if(curr_host) {
     116        if (curr_host) {
    100117            tmp_xsess = curr_host->xsession;
    101118            if (!tmp_xsess || strlen(tmp_xsess) == 0) {
    102119                tmp_xsess = g_strdup(getenv("LDM_DEFAULT_XSESSION"));
    103120                if (!tmp_xsess || strlen(tmp_xsess) == 0)
    104                     die("ldm","no Xsession");
     121                    die("ldm", "no Xsession");
    105122            }
    106123        }
     
    116133 * Then run xsession script
    117134 */
    118 void __attribute__ ((visibility("default"))) set_session_env(gchar *xsession, gchar *session) {
    119     if (g_strcmp0(session,"default") != 0 || getenv("LDM_SESSION") == NULL) {
    120         log_entry("ldm",7,"Export LDM_SELECTED_SESSION to environment: \"%s\"", session);
     135void __attribute__ ((visibility("default"))) set_session_env(gchar *
     136                                                             xsession,
     137                                                             gchar *
     138                                                             session)
     139{
     140    if (g_strcmp0(session, "default") != 0
     141        || getenv("LDM_SESSION") == NULL) {
     142        log_entry("ldm", 7,
     143                  "Export LDM_SELECTED_SESSION to environment: \"%s\"",
     144                  session);
    121145        setenv("LDM_SELECTED_SESSION", session, 1);
    122     }
    123     else {
    124         log_entry("ldm",7,"Using existing LDM_SESSION from environment: \"%s\"", getenv("LDM_SESSION"));
     146    } else {
     147        log_entry("ldm", 7,
     148                  "Using existing LDM_SESSION from environment: \"%s\"",
     149                  getenv("LDM_SESSION"));
    125150    }
    126151
     
    135160 *  Check for LTSP-Cluster. If true, contact loadbalancer for an IP
    136161 */
    137 void __attribute__ ((visibility("default"))) get_ltsp_cfg(gchar **server) {
     162void __attribute__ ((visibility("default"))) get_ltsp_cfg(gchar ** server)
     163{
    138164    /* Check for LTSP-Cluster, if true, contact the loadbalancer for an IP */
    139165    if (access(LTSP_CLUSTER_CONFILE, F_OK) == 0) {
     
    141167        fp = popen("getltscfg-cluster -l ldm", "r");
    142168        if (fp != NULL) {
    143             log_entry("ltsp-cluster",6,"IP before load-balancing: %s", *server);
     169            log_entry("ltsp-cluster", 6, "IP before load-balancing: %s",
     170                      *server);
    144171            if (fgets(*server, PATH_MAX, fp) == NULL)
    145                 log_entry("ltsp-cluster",4,"failed to get an IP from the load-balancer");
     172                log_entry("ltsp-cluster", 4,
     173                          "failed to get an IP from the load-balancer");
    146174
    147             log_entry("ltsp-cluster",6,"IP after loadbalancing: %s", *server);
     175            log_entry("ltsp-cluster", 6, "IP after loadbalancing: %s",
     176                      *server);
    148177        }
    149178        if (pclose(fp) == -1)
    150             log_entry("ltsp-cluster",3,"load-balancing failed");
     179            log_entry("ltsp-cluster", 3, "load-balancing failed");
    151180    }
    152181}
  • ldm/trunk/fuentes/src/plugins/rdesktop/rdesktop.c

    r516 r855  
    2323RdpInfo *rdpinfo;
    2424
    25 void __attribute__((constructor)) initialize() {
    26     descriptor = (LdmBackend*) malloc(sizeof(LdmBackend));
     25void __attribute__ ((constructor)) initialize()
     26{
     27    descriptor = (LdmBackend *) malloc(sizeof(LdmBackend));
    2728    bzero(descriptor, sizeof(LdmBackend));
    2829
     
    4041 *  Callback function for initialization
    4142 */
    42 void init_rdesktop() {
    43     rdpinfo = (RdpInfo*) malloc(sizeof(RdpInfo));
     43void
     44init_rdesktop()
     45{
     46    rdpinfo = (RdpInfo *) malloc(sizeof(RdpInfo));
    4447    bzero(rdpinfo, sizeof(RdpInfo));
    4548
     
    5356 *  Callback function for starting rdesktop session
    5457 */
    55 void start_rdesktop() {
     58void
     59start_rdesktop()
     60{
    5661    gboolean error = FALSE;
    5762
    5863    /* Variable validation */
    59     if(!rdpinfo->username) {
    60         log_entry("rdesktop",3,"no username");
     64    if (!rdpinfo->username) {
     65        log_entry("rdesktop", 3, "no username");
    6166        error = TRUE;
    6267    }
    6368
    64     if(!rdpinfo->password) {
    65         log_entry("rdesktop",3,"no password");
     69    if (!rdpinfo->password) {
     70        log_entry("rdesktop", 3, "no password");
    6671        error = TRUE;
    6772    }
    6873
    69     if(!rdpinfo->server) {
    70         log_entry("rdesktop",3,"no server");
     74    if (!rdpinfo->server) {
     75        log_entry("rdesktop", 3, "no server");
    7176        error = TRUE;
    7277    }
    7378
    74     if(!rdpinfo->domain) {
    75         log_entry("rdesktop",3,"no domain");
     79    if (!rdpinfo->domain) {
     80        log_entry("rdesktop", 3, "no domain");
    7681        error = TRUE;
    7782    }
    7883
    79     if(error) {
    80         die("rdesktop","missing mandatory information");
     84    if (error) {
     85        die("rdesktop", "missing mandatory information");
    8186    }
    8287
     
    8489    close_greeter();
    8590
    86     log_entry("rdesktop",6,"starting rdesktop session to '%s' as '%s'", rdpinfo->server, rdpinfo->username);
     91    log_entry("rdesktop", 6, "starting rdesktop session to '%s' as '%s'",
     92              rdpinfo->server, rdpinfo->username);
    8793    rdesktop_session();
    88     log_entry("rdesktop",6,"closing rdesktop session");
     94    log_entry("rdesktop", 6, "closing rdesktop session");
    8995}
    9096
     
    9298 * _get_domain
    9399 */
    94 void _get_domain() {
     100void
     101_get_domain()
     102{
    95103    gchar *cmd = "value domain\n";
    96104
     
    102110 *  Callback function for authentication
    103111 */
    104 void auth_rdesktop() {
     112void
     113auth_rdesktop()
     114{
    105115    gchar *cmd;
    106116
    107117    /* Separator for domains : '|' */
    108118    gchar *domains = getenv("RDP_DOMAIN");
    109     cmd = g_strconcat("pref choice;domain;Domain;Select Domai_n ...;session;", domains, "\n", NULL);
     119    cmd =
     120        g_strconcat
     121        ("pref choice;domain;Domain;Select Domai_n ...;session;", domains,
     122         "\n", NULL);
    110123    if (domains) {
    111         if(ask_greeter(cmd))
     124        if (ask_greeter(cmd))
    112125            die("rdesktop", "%s from greeter failed", cmd);
    113126    } else {
    114         log_entry("rdesktop",7,"RDP_DOMAIN isn't defined, rdesktop will connect on default domain");
     127        log_entry("rdesktop", 7,
     128                  "RDP_DOMAIN isn't defined, rdesktop will connect on default domain");
    115129    }
    116130
     
    122136
    123137    /* Get hostname */
    124     if(!rdpinfo->server)
     138    if (!rdpinfo->server)
    125139        get_host(&(rdpinfo->server));
    126140
     
    138152 *  Callback function for closing the plugins
    139153 */
    140 void close_rdesktop() {
    141     log_entry("rdesktop",7,"closing rdesktop session");
     154void
     155close_rdesktop()
     156{
     157    log_entry("rdesktop", 7, "closing rdesktop session");
    142158    free(rdpinfo);
    143159}
     
    147163 *  Start a rdesktop session to server
    148164 */
    149 void rdesktop_session() {
     165void
     166rdesktop_session()
     167{
    150168    gchar *cmd;
    151169
    152170    cmd = g_strjoin(" ", "rdesktop", "-f",
    153             "-u", rdpinfo->username,
    154             "-p", rdpinfo->password, NULL);
     171                    "-u", rdpinfo->username,
     172                    "-p", rdpinfo->password, NULL);
    155173
    156174    /* Only append the domain if it's set */
    157     if (g_strcmp0(rdpinfo->domain,"None") != 0) {
    158         cmd = g_strjoin(" ", cmd,
    159             "-d", rdpinfo->domain, NULL);
     175    if (g_strcmp0(rdpinfo->domain, "None") != 0) {
     176        cmd = g_strjoin(" ", cmd, "-d", rdpinfo->domain, NULL);
    160177    }
    161178
  • ldm/trunk/fuentes/src/plugins/ssh/Makefile.am

    r516 r855  
    44libssh_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
    55
    6 libssh_la_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS)
     6libssh_la_LDFLAGS = -lcrypt $(GLIB_LIBS) $(GOBJECT_LIBS)
    77libssh_la_SOURCES = ssh.c
  • ldm/trunk/fuentes/src/plugins/ssh/ssh.c

    r516 r855  
    1717#include <sys/stat.h>
    1818#include <utmp.h>
     19#include <crypt.h>
    1920#include <errno.h>
    2021
     
    3435SSHInfo *sshinfo;
    3536
    36 void __attribute__((constructor)) initialize() {
    37     descriptor = (LdmBackend*) malloc(sizeof(LdmBackend));
     37void __attribute__ ((constructor)) initialize()
     38{
     39    descriptor = (LdmBackend *) malloc(sizeof(LdmBackend));
    3840    bzero(descriptor, sizeof(LdmBackend));
    3941
     
    5254 *  Callback function for initialization
    5355 */
    54 void init_ssh() {
    55     sshinfo = (SSHInfo*) malloc(sizeof(SSHInfo));
     56void
     57init_ssh()
     58{
     59    sshinfo = (SSHInfo *) malloc(sizeof(SSHInfo));
    5660    bzero(sshinfo, sizeof(SSHInfo));
    5761
     
    6569 *  Start ssh session
    6670 */
    67 void start_ssh() {
     71void
     72start_ssh()
     73{
    6874    gboolean error = FALSE;
    6975
    7076    /* Variable validation */
    7177    if (!(sshinfo->username)) {
    72         log_entry("ssh",3,"no username");
     78        log_entry("ssh", 3, "no username");
    7379        error = TRUE;
    7480    }
    7581
    7682    if (!(sshinfo->password)) {
    77         log_entry("ssh",3,"no password");
     83        log_entry("ssh", 3, "no password");
    7884        error = TRUE;
    7985    }
    8086
    8187    if (!(sshinfo->server)) {
    82         log_entry("ssh",3,"no server");
     88        log_entry("ssh", 3, "no server");
    8389        error = TRUE;
    8490    }
     
    8894
    8995    if (error) {
    90         die("ssh","missing mandatory information");
     96        die("ssh", "missing mandatory information");
    9197    }
    9298
     
    101107     * control sockets.
    102108     */
    103     sshinfo->ctl_socket = g_strdup_printf("/var/run/ldm_socket_%d_%s", ldm.pid, sshinfo->server);
     109    sshinfo->ctl_socket =
     110        g_strdup_printf("/var/run/ldm_socket_%d_%s", ldm.pid,
     111                        sshinfo->server);
    104112
    105113    /* Setting ENV variables for plugin */
     
    107115
    108116    /* Execute any rc files */
    109     log_entry("ssh",6,"calling rc.d pressh scripts");
     117    log_entry("ssh", 6, "calling rc.d pressh scripts");
    110118    rc_files("pressh");
    111119
    112120    ssh_session();
    113     log_entry("ssh",6,"established ssh session on '%s' as '%s'",sshinfo->server,sshinfo->username);
     121    log_entry("ssh", 6, "established ssh session on '%s' as '%s'",
     122              sshinfo->server, sshinfo->username);
    114123
    115124    /* Greeter not needed anymore */
    116125    close_greeter();
    117126
    118     log_entry("ssh",6,"calling rc.d start scripts");
    119     rc_files("start");                      /* Execute any rc files */
    120 
    121     log_entry("ssh",6,"starting X session");
     127    log_entry("ssh", 6, "calling rc.d start scripts");
     128    rc_files("start");                           /* Execute any rc files */
     129
     130    /* ssh_hashpass - Defaults to opt-in (Must set LDM_PASSWORD_HASH to true) */
     131    if (ldm_getenv_bool_default("LDM_PASSWORD_HASH", FALSE))   
     132    {   
     133        ssh_hashpass();
     134    }
     135    else
     136    {
     137        log_entry("hashpass", 6, "LDM_PASSWORD_HASH set to FALSE or unset, skipping hash function");
     138    }       
     139    log_entry("hashpass", 6, "Freeing password as promised.");
     140    g_free(sshinfo->password);
     141    sshinfo->password = NULL;
     142
     143    log_entry("ssh", 6, "starting X session");
    122144    set_session_env(sshinfo->xsession, sshinfo->session);
    123145}
     
    127149 *  Callback function for setting guest login
    128150 */
    129 void get_guest() {
    130     log_entry("ssh",6,"setting guest login");
     151void
     152get_guest()
     153{
     154    log_entry("ssh", 6, "setting guest login");
    131155
    132156    /* Get credentials */
     
    180204        if (sshinfo->server) {
    181205            i = 0;
    182             while(1) {
    183                 if(hosts_char[i] == NULL) {
     206            while (1) {
     207                if (hosts_char[i] == NULL) {
    184208                    break;
    185209                }
    186                 if(!g_strcmp0(hosts_char[i], sshinfo->server)) {
     210                if (!g_strcmp0(hosts_char[i], sshinfo->server)) {
    187211                    good = TRUE;
    188212                    break;
     
    205229 *  Set environment variables used by LDM and Greeter
    206230 */
    207 void _set_env() {
     231void
     232_set_env()
     233{
    208234    setenv("LDM_SERVER", sshinfo->server, 1);
    209235    setenv("LDM_USERNAME", sshinfo->username, 1);
     
    215241 *  Callback function for authentication
    216242 */
    217 void get_auth() {
     243void
     244get_auth()
     245{
    218246    /* Get UserID */
    219247    get_userid(&(sshinfo->username));
     
    236264 *  Callback function for closing the plugins
    237265 */
    238 void close_ssh() {
    239     log_entry("ssh",7,"closing ssh session");
     266void
     267close_ssh()
     268{
     269    log_entry("ssh", 7, "closing ssh session");
    240270    ssh_endsession();
    241271
     
    249279}
    250280
    251 int expect(int fd, char *p, int seconds, ...) {
     281int
     282expect(int fd, char *p, int seconds, ...)
     283{
    252284    fd_set set;
    253285    struct timeval timeout;
     
    282314     * Main loop.
    283315     */
    284 
    285316    log_entry("ssh",7,"expect: entering main loop");
    286 
    287     while(1) {
     317    while (1) {
     318//        timeout.tv_sec = (long) 1;               /* one second timeout */
     319//        timeout.tv_usec = 0;
    288320        timeout.tv_sec  = 0;
    289321        timeout.tv_usec = 200000; /* 200ms timeout */
     
    293325        st = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
    294326
    295         log_entry("ssh", 7, "expect: select returned %d", st);
     327        log_entry("ssh", 7, "expect: select returned %d", st);
     328
     329//        if (st == -1 && errno == EINTR)
     330//        {
     331//            continue;                            /* interrupted by signal -> retry */
     332//        }
     333
     334//        if (st < 0) {                            /* bad thing */
     335//            break;
     336//        }
     337
     338//        if (loopcount == 0) {
     339//            break;
     340//        }
     341
     342//        if (!st) {                               /* timeout */
     343//            loopcount--;                         /* We've not seen the data we want */
     344//            continue;
     345//        }
    296346
    297347        /* There is data available - we want to read it in even if
     
    299349         * message
    300350         */
    301         if (st > 0)
    302         {
    303             size = read(fd, buffer, sizeof buffer);
    304             if (size == -1) {
    305                 log_entry("ssh", 3, "expect: read returned error %d (%s)", errno, strerror(errno));
    306                 break;
    307             }
    308             if (size == 0) {
    309                 log_entry("ssh", 3, "expect: read returned 0 (EOF))");
    310                 break;
    311             }
    312 
    313             if ((total + size) < MAXEXP) {
    314                 strncpy(p + total, buffer, size);
    315                 total += size;
    316                 log_entry("ssh", 7, "expect: got %d bytes so far", total);
    317             }
    318             else
    319             {
    320                 log_entry("ssh", 3, "expect: buffer full");
    321                 return ERROR;
    322             }
    323         }
    324         else /* No data available */
     351        if (st > 0)
     352        {
     353                size = read(fd, buffer, sizeof buffer);
     354
     355                if (size < 0) {
     356                    log_entry("ssh", 3, "expect: read returned error %d (%s)", errno, strerror(errno));
     357                    break;
     358                }
     359                if (size == 0) {
     360                        log_entry("ssh", 3, "expect: read returned 0 (EOF))");
     361                        break;
     362                }
     363
     364                if ((total + size) < MAXEXP) {
     365                    strncpy(p + total, buffer, size);
     366                    total += size;
     367                    log_entry("ssh", 7, "expect: got %d bytes so far", total);
     368                }
     369                else
     370                {
     371                        log_entry("ssh", 3, "expect: buffer full");
     372                        return ERROR;
     373                }
     374        }
     375        else /* No data available */
    325376        {
    326377            /* select() was interrupted by a signal,
     
    346397                break;
    347398            }
     399     
    348400
    349401            for (i = 0; i < expects->len; i++) {
    350                 if (strstr(p, g_ptr_array_index(expects, i))) {
    351                     log_entry("ssh", 7, "expect: found string %d \"%s\"", i, g_ptr_array_index(expects, i));
    352                     loopend = TRUE;
    353                     break;
    354                 }
    355             }
    356 
    357             loopcount--;            /* We've not seen the data we want */
    358         }
     402                if (strstr(p, g_ptr_array_index(expects, i))) {
     403                        log_entry("ssh", 7, "expect: found string %d \"%s\"", i, g_ptr_array_index(expects, i));
     404                        loopend = TRUE;
     405                        break;
     406                }
     407            }
     408            loopcount--;            /* We've not seen the data we want */
     409        }
    359410
    360411        if (loopend) {
     
    365416    log_entry("ssh",7,"expect: saw: %s", p);
    366417
    367     if (size < 0 || st < 0 || child_exited) {
    368         return ERROR;               /* error occured */
     418    if (size < 0 || st < 0) {
     419        return ERROR;                            /* error occured */
    369420    }
    370421    if (loopcount == 0) {
    371         return TIMED_OUT;           /* timed out */
    372     } else {
    373         return i;                   /* which expect did we see? */
    374     }
    375 }
    376 
    377 void ssh_chat(gint fd) {
     422        return TIMED_OUT;                        /* timed out */
     423    }
     424    /* Sleep a bit to make sure we notice if ssh died in the meantime */
     425    usleep(100000);
     426    if (child_exited)
     427    {
     428        return ERROR;
     429    }
     430
     431    return i;                                    /* which expect did we see? */
     432}
     433
     434void
     435ssh_chat(gint fd)
     436{
    378437    int seen;
    379438    size_t len;
     
    396455           end of the line */
    397456        if (seen == 0) {
    398             g_free(sshinfo->password);
    399             sshinfo->password = NULL;
    400457            return;
    401         } else if (seen == 1) {
    402             int i;
    403             g_strdelimit(lastseen, "\r\n\t", ' ');
    404             g_strchomp(lastseen);
    405             i = strlen(lastseen);
     458        }
     459
     460        int i;
     461        g_strdelimit(lastseen, "\r\n\t", ' ');
     462        g_strchomp(lastseen);
     463        i = strlen(lastseen);
     464
     465        if (seen == 1) {
    406466            /* If it's not the first time through, or the :'s not at the
    407467             * end of a line (password expiry or error), set the message */
     
    439499}
    440500
    441 void ssh_tty_init(void) {
     501void
     502ssh_tty_init(void)
     503{
    442504    (void) setsid();
    443     if (login_tty(sshinfo->sshslavefd) < 0 ) {
    444         die("ssh","login_tty failed");
     505    if (login_tty(sshinfo->sshslavefd) < 0) {
     506        die("ssh", "login_tty failed");
    445507    }
    446508}
     
    450512 * Start an ssh login to the server.
    451513 */
    452 void ssh_session(void) {
     514void
     515ssh_session(void)
     516{
    453517    gchar *command;
    454518    gchar *port = NULL;
     
    456520
    457521    /* Check for port Override */
    458     if(sshinfo->override_port)
    459         port = g_strconcat(" -p ", sshinfo->override_port, " ",  NULL);
     522    if (sshinfo->override_port)
     523        port = g_strconcat(" -p ", sshinfo->override_port, " ", NULL);
    460524
    461525    openpty(&(sshinfo->sshfd), &(sshinfo->sshslavefd), NULL, NULL, NULL);
    462526
    463527    command = g_strjoin(" ", "ssh", "-Y", "-t", "-M",
    464             "-S", sshinfo->ctl_socket,
    465             "-o", "NumberOfPasswordPrompts=1",
    466              /* ConnectTimeout should be less than the timeout ssh_chat
    467               * passes to expect, so we get the error message from ssh
    468               * before expect gives up
    469               */
    470             "-o", "ConnectTimeout=10",
    471             "-l", sshinfo->username,
    472             port ? port : "",
    473             sshinfo->sshoptions ? sshinfo->sshoptions : "",
    474             sshinfo->server, "echo " SENTINEL "; exec /bin/sh -", NULL);
     528                        "-S", sshinfo->ctl_socket,
     529                        "-o", "NumberOfPasswordPrompts=1",
     530                         /* ConnectTimeout should be less than the timeout ssh_chat
     531                          * passes to expect, so we get the error message from ssh
     532                          * before expect gives up
     533                          */
     534                        "-o", "ConnectTimeout=10",
     535                        "-l", sshinfo->username,
     536                        port ? port : "",
     537                        sshinfo->sshoptions ? sshinfo->sshoptions : "",
     538                        sshinfo->server,
     539                        "echo " SENTINEL "; exec /bin/sh -", NULL);
    475540    log_entry("ssh", 6, "ssh_session: %s", command);
    476541
     
    488553}
    489554
    490 void ssh_endsession(void) {
     555void
     556ssh_endsession(void)
     557{
    491558    GPid pid;
    492559    gchar *command;
     
    496563        /* socket still exists, so we need to shut down the ssh link */
    497564
    498         command = g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit", sshinfo->server, NULL);
    499         log_entry("ssh", 6, "closing ssh session: %s", command);
     565        command =
     566            g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit",
     567                      sshinfo->server, NULL);
     568        log_entry("ssh", 6, "closing ssh session: %s"), command;
    500569        pid = ldm_spawn(command, NULL, NULL, NULL);
    501570        ldm_wait(pid);
     
    507576}
    508577
    509 void *eater() {
     578/*
     579 * ssh_hashpass()
     580 * Set up password hash for client /etc/shadow using /dev/urandom
     581 * rather than g_rand() due to developer recommendations at:
     582 * https://developer.gnome.org/glib/stable/glib-Random-Numbers.html
     583 */
     584void
     585ssh_hashpass(void)
     586{
     587    FILE *rand_fp;
     588    FILE *shad_fp;
     589    gchar salt[] = "$6$...............$";
     590    gchar buf[16];
     591    const gchar seedchars[] =
     592        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     593    gchar *shadowentry;
     594    const gchar hashloc[] = "/var/cache/ltsp/shadow.sed";
     595    size_t i = 0;
     596    log_entry("hashpass", 6, "LDM_PASSWORD_HASH set to true, setting hash");       
     597    rand_fp = fopen("/dev/urandom", "r");
     598    if (rand_fp == NULL)
     599    {
     600        log_entry("hashpass", 7, "Unable to read from /dev/urandom - Skipping HASH function");
     601    }
     602    else
     603    {     
     604        fread(buf, sizeof buf, 1, rand_fp);
     605        fclose(rand_fp);
     606        for (; i < sizeof buf; i++)
     607        {
     608            salt[3 + i] = seedchars[buf[i] % (sizeof seedchars - 1)];
     609        }
     610        shadowentry = crypt(sshinfo->password, salt);
     611        log_entry("hashpass", 6, "hash created");
     612        /* generate dynamic file for writing hash to.
     613        * Will remove anything in its way.
     614        * This will be removed during rc.d script run.
     615        */
     616        shad_fp = fopen(hashloc, "w");
     617        if (shad_fp == NULL)
     618        {
     619            log_entry("hashpass", 7, "Unable to open %s for hash entry.",
     620                      hashloc);
     621        }
     622        else
     623        {
     624            fprintf(shad_fp,
     625                    "# Generated by LTSP, for LDM rc.d script manipulation\n$s:!:%s:",
     626                    shadowentry);
     627            fclose(shad_fp);
     628        }
     629    }
     630}
     631
     632void *
     633eater()
     634{
    510635    fd_set set;
    511636    struct timeval timeout;
     
    519644        }
    520645
    521         timeout.tv_sec = (long)1;             /* one second timeout */
     646        timeout.tv_sec = (long) 1;               /* one second timeout */
    522647        timeout.tv_usec = 0;
    523648        FD_ZERO(&set);
  • ldm/trunk/fuentes/src/plugins/ssh/ssh.h

    r516 r855  
    3030void ssh_session(void);
    3131void ssh_tty_init();
     32void ssh_hashpass(void);
    3233
    3334int expect(int, char*,int,...);
  • ldm/trunk/fuentes/wwm/client.c

    r516 r855  
    2121    for (c = head_client; c; c = c->next)
    2222        if (w == c->parent || w == c->window)
    23             return(c);
    24     return(NULL);
     23            return (c);
     24    return (NULL);
    2525}
    2626
    2727Client *
    28 next_client_on_vdesk(Client *c)
     28next_client_on_vdesk(Client * c)
    2929{
    3030    Client *newc = c, *marker = c;
     
    3838    while (newc != marker && newc->vdesk != v);
    3939
    40     return((newc == marker) ? NULL : newc);
    41 }
    42 
    43 void
    44 set_wm_state(Client *c, int state)
     40    return ((newc == marker) ? NULL : newc);
     41}
     42
     43void
     44set_wm_state(Client * c, int state)
    4545{
    4646    long data[2];
    4747
    4848    data[0] = (long) state;
    49     data[1] = None;                         /* icon window */
     49    data[1] = None;                              /* icon window */
    5050
    5151    XChangeProperty(display, c->window, xa_wm_state, xa_wm_state,
     
    5555
    5656void
    57 send_config(Client *c)
     57send_config(Client * c)
    5858{
    5959    XConfigureEvent ce;
    6060
    61     ce.type              = ConfigureNotify;
    62     ce.event             = c->window;
    63     ce.window            = c->window;
    64     ce.x                 = c->x;
    65     ce.y                 = c->y;
    66     ce.width             = c->width;
    67     ce.height            = c->height;
    68     ce.border_width      = c->border;
    69     ce.above             = None;
     61    ce.type = ConfigureNotify;
     62    ce.event = c->window;
     63    ce.window = c->window;
     64    ce.x = c->x;
     65    ce.y = c->y;
     66    ce.width = c->width;
     67    ce.height = c->height;
     68    ce.border_width = c->border;
     69    ce.above = None;
    7070    ce.override_redirect = False;
    7171
    72     XSendEvent(display, c->window, False, StructureNotifyMask, (XEvent *) &ce);
     72    XSendEvent(display, c->window, False, StructureNotifyMask,
     73               (XEvent *) & ce);
    7374    XSync(display, False);
    7475}
    7576
    7677void
    77 remove_client(Client *c, int from_cleanup)
     78remove_client(Client * c, int from_cleanup)
    7879{
    7980    Window root = ROOTWINDOW;
     
    105106        XFree(c->size);
    106107    if (current == c)
    107         current = NULL;     /* an enter event should set this up again */
     108        current = NULL;                          /* an enter event should set this up again */
    108109    free(c);
    109110
     
    114115
    115116void
    116 change_gravity(Client *c, int invert)
     117change_gravity(Client * c, int invert)
    117118{
    118119    int dx = 0, dy = 0;
    119120    int gravity = (c->size->flags & PWinGravity) ?
    120                    c->size->win_gravity : NorthWestGravity;
     121        c->size->win_gravity : NorthWestGravity;
    121122
    122123    switch (gravity) {
    123         case CenterGravity:
    124         case StaticGravity:
    125         case NorthWestGravity:
    126         case NorthGravity:
    127         case WestGravity:
    128             dx = c->border;
    129             dy = c->border;
    130             break;
    131         case NorthEastGravity:
    132         case EastGravity:
    133             dx = -(c->border);
    134             dy = c->border;
    135             break;
    136         case SouthEastGravity:
    137             dx = -(c->border);
    138             dy = -(c->border);
    139             break;
    140         case SouthGravity:
    141         case SouthWestGravity:
    142             dx = c->border;
    143             dy = -(c->border);
    144             break;
     124    case CenterGravity:
     125    case StaticGravity:
     126    case NorthWestGravity:
     127    case NorthGravity:
     128    case WestGravity:
     129        dx = c->border;
     130        dy = c->border;
     131        break;
     132    case NorthEastGravity:
     133    case EastGravity:
     134        dx = -(c->border);
     135        dy = c->border;
     136        break;
     137    case SouthEastGravity:
     138        dx = -(c->border);
     139        dy = -(c->border);
     140        break;
     141    case SouthGravity:
     142    case SouthWestGravity:
     143        dx = c->border;
     144        dy = -(c->border);
     145        break;
    145146    }
    146147
     
    155156
    156157void
    157 send_wm_delete(Client *c)
     158send_wm_delete(Client * c)
    158159{
    159160    int i, n, found = 0;
     
    181182    XEvent ev;
    182183
    183     ev.type                 = ClientMessage;
    184     ev.xclient.window       = w;
     184    ev.type = ClientMessage;
     185    ev.xclient.window = w;
    185186    ev.xclient.message_type = a;
    186     ev.xclient.format       = 32;
    187     ev.xclient.data.l[0]    = x;
    188     ev.xclient.data.l[1]    = CurrentTime;
    189 
    190     return(XSendEvent(display, w, False, NoEventMask, &ev));
    191 }
    192 
    193 void
    194 set_shape(Client *c) {
    195     int i, b;  unsigned int u;  /* dummies */
     187    ev.xclient.format = 32;
     188    ev.xclient.data.l[0] = x;
     189    ev.xclient.data.l[1] = CurrentTime;
     190
     191    return (XSendEvent(display, w, False, NoEventMask, &ev));
     192}
     193
     194void
     195set_shape(Client * c)
     196{
     197    int i, b;
     198    unsigned int u;             /* dummies */
    196199    int bounding_shaped;
    197200    Status retval;
     
    209212     */
    210213
    211     retval = XShapeQueryExtents(display, c->window, &bounding_shaped, &i, &i,
    212              &u, &u, &b, &i, &i, &u, &u);
     214    retval =
     215        XShapeQueryExtents(display, c->window, &bounding_shaped, &i, &i,
     216                           &u, &u, &b, &i, &i, &u, &u);
    213217    if (retval && bounding_shaped)
    214218        XShapeCombineShape(display, c->parent, ShapeBounding,
    215             c->border, c->border, c->window, ShapeBounding, ShapeSet);
    216 }
     219                           c->border, c->border, c->window, ShapeBounding,
     220                           ShapeSet);
     221}
  • ldm/trunk/fuentes/wwm/events.c

    r516 r855  
    1010
    1111void
    12 handle_key_event(XKeyEvent *e)
     12handle_key_event(XKeyEvent * e)
    1313{
    1414    int i;
     
    3535    for (i = 0; keytab[i].key != 0; i++)
    3636        if (keytab[i].key == key) {
    37             keytab[i].f(c);             /* dispatch the function */
     37            keytab[i].f(c);                      /* dispatch the function */
    3838            break;
    3939        }
     
    4141
    4242void
    43 handle_button_event(XButtonEvent *e)
     43handle_button_event(XButtonEvent * e)
    4444{
    4545    // We want a minimal WM, so no mouse actions
     
    5252        return;
    5353        switch (e->button) {
    54             case Button4:               /* Scrolly wheel up in root */
    55                 prev_vdesk((Client *) NULL);
    56                 return;
    57             case Button5:               /* Scrolly wheel down in root */
    58                 next_vdesk((Client *) NULL);
    59                 return;
     54        case Button4:                           /* Scrolly wheel up in root */
     55            prev_vdesk((Client *) NULL);
     56            return;
     57        case Button5:                           /* Scrolly wheel down in root */
     58            next_vdesk((Client *) NULL);
     59            return;
    6060        }
    6161    } else if (c) {
    6262        switch (e->button) {
    63             case Button1:               /* Left mouse = move */
    64                 move(c, 0);
    65                 return;
    66             case Button3:               /* Right mouse = resize */
    67                 resize(c, 0);
     63        case Button1:                           /* Left mouse = move */
     64            move(c, 0);
     65            return;
     66        case Button3:                           /* Right mouse = resize */
     67            resize(c, 0);
    6868            return;
    6969        }
     
    7272
    7373void
    74 handle_shape_event(XShapeEvent *e) {
     74handle_shape_event(XShapeEvent * e)
     75{
    7576    Client *c = find_client(e->window);
    7677
     
    8081
    8182void
    82 handle_configure_request(XConfigureRequestEvent *e)
     83handle_configure_request(XConfigureRequestEvent * e)
    8384{
    8485    Client *c = find_client(e->window);
     
    122123
    123124void
    124 handle_map_request(XMapRequestEvent *e)
     125handle_map_request(XMapRequestEvent * e)
    125126{
    126127    Client *c = find_client(e->window);
     
    135136
    136137void
    137 handle_unmap_event(XUnmapEvent *e)
     138handle_unmap_event(XUnmapEvent * e)
    138139{
    139140    Client *c = find_client(e->window);
     
    157158
    158159void
    159 handle_client_message(XClientMessageEvent *e)
     160handle_client_message(XClientMessageEvent * e)
    160161{
    161162    Client *c = find_client(e->window);
    162163
    163     if (c &&                                        /* Client exists */
    164         e->message_type == xa_wm_change_state &&    /* Changing state */
    165         e->format == sz_xInternAtomReply &&         /* Data is long */
    166         e->data.l[0] == IconicState)                /* We're now iconic */
     164    if (c &&                                     /* Client exists */
     165        e->message_type == xa_wm_change_state && /* Changing state */
     166        e->format == sz_xInternAtomReply &&      /* Data is long */
     167        e->data.l[0] == IconicState)             /* We're now iconic */
    167168        hide(c);
    168169}
    169170
    170171void
    171 handle_property_change(XPropertyEvent *e)
     172handle_property_change(XPropertyEvent * e)
    172173{
    173174    Client *c = find_client(e->window);
     
    180181
    181182void
    182 handle_enter_event(XCrossingEvent *e)
     183handle_enter_event(XCrossingEvent * e)
    183184{
    184185    Client *c = find_client(e->window);
    185186
    186     if (nomousefocus || !c)           /* Ignore focus follows mouse */
     187    if (nomousefocus || !c)                      /* Ignore focus follows mouse */
    187188        return;
    188189
  • ldm/trunk/fuentes/wwm/main.c

    r516 r855  
    1414#include "wwm.h"
    1515
    16 void handle_shape_event(XShapeEvent *e);
     16void handle_shape_event(XShapeEvent * e);
    1717
    1818/*
     
    2020 */
    2121
    22 Client *head_client = NULL;    /* First client */
    23 Client *current = NULL;        /* "current" client */
    24 Display *display;            /* Our display */
    25 Atom xa_wm_state;            /* atoms for window manager functions */
     22Client *head_client = NULL;     /* First client */
     23Client *current = NULL;         /* "current" client */
     24Display *display;               /* Our display */
     25Atom xa_wm_state;               /* atoms for window manager functions */
    2626Atom xa_wm_change_state;
    2727Atom xa_wm_protos;
    2828Atom xa_wm_delete;
    29 XColor fg, bg, fc;            /* Forground, Background, and locked colours */
    30 int nomousefocus = 0;        /* focus follows mouse status */
    31 int passthrough = 0;        /* current passthrough state */
    32 char *term = NULL;          /* terminal to launch */
    33 int have_shape = 0;         /* Do we support shaped windows? */
    34 int ignore_xerror = 0;      /* Ignore X errors */
     29XColor fg, bg, fc;              /* Forground, Background, and locked colours */
     30int nomousefocus = 0;           /* focus follows mouse status */
     31int passthrough = 0;            /* current passthrough state */
     32char *term = NULL;              /* terminal to launch */
     33int have_shape = 0;             /* Do we support shaped windows? */
     34int ignore_xerror = 0;          /* Ignore X errors */
    3535
    3636struct wmkeys keytab[] = {
     
    4646    int shape_event;
    4747
    48     dpy = getenv("DISPLAY");            /* manage the display in $DISPLAY */
     48    dpy = getenv("DISPLAY");                     /* manage the display in $DISPLAY */
    4949
    5050    if (!dpy)
     
    5454    sigemptyset(&act.sa_mask);
    5555#ifdef SA_NOCLDSTOP
    56     act.sa_flags = SA_NOCLDSTOP;        /* don't care about STOP, CONT */
     56    act.sa_flags = SA_NOCLDSTOP;                 /* don't care about STOP, CONT */
    5757#else
    5858    act.sa_flags = 0;
    5959#endif
    6060    sigaction(SIGTERM, &act, NULL);
    61     sigaction(SIGINT,  &act, NULL);
    62     sigaction(SIGHUP,  &act, NULL);
     61    sigaction(SIGINT, &act, NULL);
     62    sigaction(SIGHUP, &act, NULL);
    6363    sigaction(SIGCHLD, &act, NULL);
    6464
     
    9090        XNextEvent(display, &ev);
    9191        switch (ev.type) {
    92             case KeyPress:
    93                 handle_key_event(&ev.xkey);
    94                 break;
    95             case ButtonPress:
    96                 handle_button_event(&ev.xbutton);
    97                 break;
    98             case ConfigureRequest:
    99                 handle_configure_request(&ev.xconfigurerequest);
    100                 break;
    101             case MapRequest:
    102                 handle_map_request(&ev.xmaprequest);
    103                 break;
    104             case ClientMessage:
    105                 handle_client_message(&ev.xclient);
    106                 break;
    107             case EnterNotify:
    108                 handle_enter_event(&ev.xcrossing);
    109                 break;
    110             case PropertyNotify:
    111                 handle_property_change(&ev.xproperty);
    112                 break;
    113             case UnmapNotify:
    114                 handle_unmap_event(&ev.xunmap);
    115                 break;
    116             default:
    117                 if (have_shape && ev.type == shape_event) {
    118                     handle_shape_event((XShapeEvent *)&ev);
    119                 }
     92        case KeyPress:
     93            handle_key_event(&ev.xkey);
     94            break;
     95        case ButtonPress:
     96            handle_button_event(&ev.xbutton);
     97            break;
     98        case ConfigureRequest:
     99            handle_configure_request(&ev.xconfigurerequest);
     100            break;
     101        case MapRequest:
     102            handle_map_request(&ev.xmaprequest);
     103            break;
     104        case ClientMessage:
     105            handle_client_message(&ev.xclient);
     106            break;
     107        case EnterNotify:
     108            handle_enter_event(&ev.xcrossing);
     109            break;
     110        case PropertyNotify:
     111            handle_property_change(&ev.xproperty);
     112            break;
     113        case UnmapNotify:
     114            handle_unmap_event(&ev.xunmap);
     115            break;
     116        default:
     117            if (have_shape && ev.type == shape_event) {
     118                handle_shape_event((XShapeEvent *) & ev);
     119            }
    120120        }
    121121    }
    122122
    123     return(1);                          /* ?!?  shouldn't get here */
     123    return (1);                                  /* ?!?  shouldn't get here */
    124124}
    125125
     
    145145
    146146    display = XOpenDisplay(dpy);
    147     if (!display)                           /* couldn't open display */
     147    if (!display)                                /* couldn't open display */
    148148        exit(1);
    149149
     
    159159     */
    160160
    161     xa_wm_state        = XInternAtom(display, "WM_STATE",        False);
    162     xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE",  False);
    163     xa_wm_protos       = XInternAtom(display, "WM_PROTOCOLS",    False);
    164     xa_wm_delete       = XInternAtom(display, "WM_DELETE_WINDOW", False);
     161    xa_wm_state = XInternAtom(display, "WM_STATE", False);
     162    xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
     163    xa_wm_protos = XInternAtom(display, "WM_PROTOCOLS", False);
     164    xa_wm_delete = XInternAtom(display, "WM_DELETE_WINDOW", False);
    165165
    166166    XAllocNamedColor(display, colormap, DEF_FG, &fg, &dummy);
     
    184184
    185185    attr.event_mask = KeyPressMask | ChildMask | PropertyChangeMask |
    186                       EnterWindowMask | ButtonMask;
     186        EnterWindowMask | ButtonMask;
    187187    XChangeWindowAttributes(display, root, CWEventMask, &attr);
    188188
     
    202202    Window root = RootWindow(display, DefaultScreen(display));
    203203    XGrabKey(display, XKeysymToKeycode(display, keycode),
    204          modifiers, root, True, GrabModeAsync, GrabModeAsync);
     204             modifiers, root, True, GrabModeAsync, GrabModeAsync);
    205205}
    206206
  • ldm/trunk/fuentes/wwm/mapfunctions.c

    r516 r855  
    1515
    1616void
    17 move_win_up(Client *c)
     17move_win_up(Client * c)
    1818{
    1919    if (!c)
     
    2828
    2929void
    30 move_win_down(Client *c)
     30move_win_down(Client * c)
    3131{
    3232    if (!c)
     
    4141
    4242void
    43 move_win_left(Client *c)
     43move_win_left(Client * c)
    4444{
    4545    if (!c)
     
    5454
    5555void
    56 move_win_right(Client *c)
     56move_win_right(Client * c)
    5757{
    5858    if (!c)
     
    6767
    6868void
    69 expand_win_y(Client *c)
     69expand_win_y(Client * c)
    7070{
    7171    if (!c)
     
    8080
    8181void
    82 contract_win_y(Client *c)
     82contract_win_y(Client * c)
    8383{
    8484    if (!c || c->height <= WMDELTA)
     
    8989
    9090void
    91 expand_win_x(Client *c)
     91expand_win_x(Client * c)
    9292{
    9393    if (!c)
     
    9898
    9999void
    100 contract_win_x(Client *c)
     100contract_win_x(Client * c)
    101101{
    102102    if (!c || c->width <= WMDELTA)
     
    107107
    108108void
    109 kill_client(Client *c)
     109kill_client(Client * c)
    110110{
    111111    if (!c)
     
    115115
    116116void
    117 raise_client(Client *c)
     117raise_client(Client * c)
    118118{
    119119    if (!c)
     
    123123
    124124void
    125 lower_client(Client *c)
     125lower_client(Client * c)
    126126{
    127127    if (!c)
     
    131131
    132132void
    133 horizontal_toggle(Client *c)
     133horizontal_toggle(Client * c)
    134134{
    135135    if (!c)
     
    140140
    141141void
    142 vertical_toggle(Client *c)
     142vertical_toggle(Client * c)
    143143{
    144144    if (!c)
     
    149149
    150150void
    151 maximize_toggle(Client *c)
     151maximize_toggle(Client * c)
    152152{
    153153    if (!c)
     
    159159
    160160void
    161 lock_window(Client *c)
     161lock_window(Client * c)
    162162{
    163163    if (!c)
    164164        return;
    165165    XSetWindowBackground(display, c->parent,
    166              c->vdesk == LOCKED ? fg.pixel : fc.pixel);
     166                         c->vdesk == LOCKED ? fg.pixel : fc.pixel);
    167167    XClearWindow(display, c->parent);
    168168    c->vdesk = c->vdesk == LOCKED ? vdesk_get() : LOCKED;
     
    170170
    171171void
    172 new_term(Client *c)
     172new_term(Client * c)
    173173{
    174174    spawn(term);
     
    176176
    177177void
    178 next_client(Client *c)
     178next_client(Client * c)
    179179{
    180180    next(current);
     
    182182
    183183void
    184 quit_wm(Client *c)
     184quit_wm(Client * c)
    185185{
    186186    handle_signal(SIGHUP);
     
    188188
    189189void
    190 start_passthrough(Client *c)
     190start_passthrough(Client * c)
    191191{
    192192    passthrough++;
     
    194194
    195195void
    196 goto_vdesk_0(Client *c)
     196goto_vdesk_0(Client * c)
    197197{
    198198    switch_vdesk(0);
     
    200200
    201201void
    202 goto_vdesk_1(Client *c)
     202goto_vdesk_1(Client * c)
    203203{
    204204    switch_vdesk(1);
     
    206206
    207207void
    208 goto_vdesk_2(Client *c)
     208goto_vdesk_2(Client * c)
    209209{
    210210    switch_vdesk(2);
     
    212212
    213213void
    214 goto_vdesk_3(Client *c)
     214goto_vdesk_3(Client * c)
    215215{
    216216    switch_vdesk(3);
     
    218218
    219219void
    220 goto_vdesk_4(Client *c)
     220goto_vdesk_4(Client * c)
    221221{
    222222    switch_vdesk(4);
     
    224224
    225225void
    226 goto_vdesk_5(Client *c)
     226goto_vdesk_5(Client * c)
    227227{
    228228    switch_vdesk(5);
     
    230230
    231231void
    232 goto_vdesk_6(Client *c)
     232goto_vdesk_6(Client * c)
    233233{
    234234    switch_vdesk(6);
     
    236236
    237237void
    238 goto_vdesk_7(Client *c)
     238goto_vdesk_7(Client * c)
    239239{
    240240    switch_vdesk(7);
     
    242242
    243243void
    244 prev_vdesk(Client *c)
     244prev_vdesk(Client * c)
    245245{
    246246    int v = vdesk(VDESK_PREV, VDESK_NULL);
     
    250250
    251251void
    252 next_vdesk(Client *c)
     252next_vdesk(Client * c)
    253253{
    254254    int v = vdesk(VDESK_NEXT, VDESK_NULL);
     
    258258
    259259void
    260 top_left(Client *c)
     260top_left(Client * c)
    261261{
    262262    if (!c)
     
    269269
    270270void
    271 top_right(Client *c)
     271top_right(Client * c)
    272272{
    273273    if (!c)
     
    280280
    281281void
    282 bottom_left(Client *c)
     282bottom_left(Client * c)
    283283{
    284284    if (!c)
     
    291291
    292292void
    293 bottom_right(Client *c)
     293bottom_right(Client * c)
    294294{
    295295    if (!c)
     
    302302
    303303void
    304 toggle_focus(Client *c)
     304toggle_focus(Client * c)
    305305{
    306306    nomousefocus = (nomousefocus + 1) % 2;
     
    308308
    309309void
    310 dummy_func(Client *c)
     310dummy_func(Client * c)
    311311{
    312312    return;
  • ldm/trunk/fuentes/wwm/misc.c

    r516 r855  
    5353
    5454int
    55 handle_xerror(Display *dpy, XErrorEvent *e)
     55handle_xerror(Display * dpy, XErrorEvent * e)
    5656{
    5757    Client *c = find_client(e->resourceid);
    5858
    5959    if (ignore_xerror)
    60         return(0);
     60        return (0);
    6161
    6262    if (e->error_code == BadAccess &&
     
    6767        remove_client(c, NOT_QUITTING);
    6868
    69     return(0);
     69    return (0);
    7070}
    7171
    7272int
    73 handle_xexit(Display *dpy)
     73handle_xexit(Display * dpy)
    7474{
    7575    exit(0);
     
    8282
    8383    switch (vdesk_command) {
    84         case VDESK_GET:
    85             return(my_vdesk);
    86         case VDESK_SET:
    87             my_vdesk = vdesk_option;
    88             return(my_vdesk);
    89         case VDESK_NEXT:
    90             return((my_vdesk + 1) % VDESK_MAX);
    91         case VDESK_PREV:
    92             return((my_vdesk ? my_vdesk - 1 : ( VDESK_MAX - 1)) % VDESK_MAX);
    93         default:
    94             return(my_vdesk);
     84    case VDESK_GET:
     85        return (my_vdesk);
     86    case VDESK_SET:
     87        my_vdesk = vdesk_option;
     88        return (my_vdesk);
     89    case VDESK_NEXT:
     90        return ((my_vdesk + 1) % VDESK_MAX);
     91    case VDESK_PREV:
     92        return ((my_vdesk ? my_vdesk - 1 : (VDESK_MAX - 1)) % VDESK_MAX);
     93    default:
     94        return (my_vdesk);
    9595    }
    9696}
  • ldm/trunk/fuentes/wwm/new.c

    r516 r855  
    8686    XGetWindowAttributes(display, c->window, &attr);
    8787
    88     c->x      = attr.x;
    89     c->y      = attr.y;
    90     c->width  = attr.width;
     88    c->x = attr.x;
     89    c->y = attr.y;
     90    c->width = attr.width;
    9191    c->height = attr.height;
    9292    c->border = DEF_BW;
    93     c->oldw   = c->oldh = 0;
    94     c->vdesk  = vdesk_get();
     93    c->oldw = c->oldh = 0;
     94    c->vdesk = vdesk_get();
    9595
    9696    /*
     
    131131    }
    132132
    133     focus_client(c, RAISE);        /* new windows get focus */
     133    focus_client(c, RAISE);                      /* new windows get focus */
    134134}
    135135
    136136void
    137 init_position(Client *c)
     137init_position(Client * c)
    138138{
    139139    int x, y;
     
    171171
    172172void
    173 reparent(Client *c)
     173reparent(Client * c)
    174174{
    175175    XSetWindowAttributes p_attr;
     
    182182    p_attr.background_pixel = bg.pixel;
    183183    p_attr.event_mask =
    184     ChildMask | ButtonPressMask | ExposureMask | EnterWindowMask;
     184        ChildMask | ButtonPressMask | ExposureMask | EnterWindowMask;
    185185    c->parent =
    186186        XCreateWindow(display, root, c->x - c->border,
    187               c->y - c->border, c->width + (2 * c->border),
    188               c->height + (2 * c->border), 0, DefaultDepth(display,
    189                                    screen),
    190               CopyFromParent, DefaultVisual(display, screen),
    191               CWOverrideRedirect | CWBackPixel | CWEventMask,
    192               &p_attr);
     187                      c->y - c->border, c->width + (2 * c->border),
     188                      c->height + (2 * c->border), 0, DefaultDepth(display,
     189                                                                   screen),
     190                      CopyFromParent, DefaultVisual(display, screen),
     191                      CWOverrideRedirect | CWBackPixel | CWEventMask,
     192                      &p_attr);
    193193
    194194    XAddToSaveSet(display, c->window);
  • ldm/trunk/fuentes/wwm/screen.c

    r516 r855  
    88
    99void
    10 draw_outline(Client *c)
     10draw_outline(Client * c)
    1111{
    1212    Window root = ROOTWINDOW;
     
    2020        gv.function = GXinvert;
    2121        gv.subwindow_mode = IncludeInferiors;
    22         gv.line_width = DEF_BW; /* opt_bw */
     22        gv.line_width = DEF_BW;                  /* opt_bw */
    2323
    2424        invert_gc = XCreateGC(display, root,
    25                               GCFunction | GCSubwindowMode | GCLineWidth, &gv);
     25                              GCFunction | GCSubwindowMode | GCLineWidth,
     26                              &gv);
    2627    }
    2728
     
    4344
    4445void
    45 recalculate_sweep(Client *c, int x1, int y1, int x2, int y2)
     46recalculate_sweep(Client * c, int x1, int y1, int x2, int y2)
    4647{
    4748    int basex, basey;
     
    5253    if (c->size->flags & PResizeInc) {
    5354        basex = (c->size->flags & PBaseSize) ? c->size->base_width :
    54                 (c->size->flags & PMinSize) ? c->size->min_width : 0;
     55            (c->size->flags & PMinSize) ? c->size->min_width : 0;
    5556        basey = (c->size->flags & PBaseSize) ? c->size->base_height :
    56                 (c->size->flags & PMinSize) ? c->size->min_height : 0;
     57            (c->size->flags & PMinSize) ? c->size->min_height : 0;
    5758        c->width -= (c->width - basex) % c->size->width_inc;
    5859        c->height -= (c->height - basey) % c->size->height_inc;
     
    7879
    7980void
    80 sweep(Client *c)
     81sweep(Client * c)
    8182{
    8283    Window root = ROOTWINDOW;
     
    99100    draw_outline(c);
    100101
    101     XWarpPointer(display, None, c->window, 0, 0, 0, 0, c->width, c->height);
     102    XWarpPointer(display, None, c->window, 0, 0, 0, 0, c->width,
     103                 c->height);
    102104
    103105    for (;;) {
    104106        XMaskEvent(display, MouseMask, &ev);
    105107        switch (ev.type) {
    106             case MotionNotify:
    107                 draw_outline(c);    /* clear */
    108                 XUngrabServer(display);
    109                 recalculate_sweep(c, old_cx, old_cy,
    110                                   ev.xmotion.x, ev.xmotion.y);
    111                 XSync(display, False);
    112                 XGrabServer(display);
    113                 draw_outline(c);
    114                 break;
    115             case ButtonRelease:
    116                 draw_outline(c);    /* clear */
    117                 XUngrabServer(display);
    118                 XUngrabPointer(display, CurrentTime);
    119                 return;
     108        case MotionNotify:
     109            draw_outline(c);                     /* clear */
     110            XUngrabServer(display);
     111            recalculate_sweep(c, old_cx, old_cy,
     112                              ev.xmotion.x, ev.xmotion.y);
     113            XSync(display, False);
     114            XGrabServer(display);
     115            draw_outline(c);
     116            break;
     117        case ButtonRelease:
     118            draw_outline(c);                     /* clear */
     119            XUngrabServer(display);
     120            XUngrabPointer(display, CurrentTime);
     121            return;
    120122        }
    121123    }
     
    123125
    124126void
    125 drag(Client *c)
     127drag(Client * c)
    126128{
    127129    Window root = ROOTWINDOW;
     
    146148        XMaskEvent(display, MouseMask, &ev);
    147149        switch (ev.type) {
    148             case MotionNotify:
    149                 draw_outline(c);    /* clear */
    150                 XUngrabServer(display);
    151                 c->x = old_cx + (ev.xmotion.x - x1);
    152                 c->y = old_cy + (ev.xmotion.y - y1);
    153                 XSync(display, False);
    154                 XGrabServer(display);
    155                 draw_outline(c);
    156                 break;
    157             case ButtonRelease:
    158                 draw_outline(c);    /* clear */
    159                 XUngrabServer(display);
    160                 XUngrabPointer(display, CurrentTime);
    161                 return;
    162             default:
    163                 break;
     150        case MotionNotify:
     151            draw_outline(c);                     /* clear */
     152            XUngrabServer(display);
     153            c->x = old_cx + (ev.xmotion.x - x1);
     154            c->y = old_cy + (ev.xmotion.y - y1);
     155            XSync(display, False);
     156            XGrabServer(display);
     157            draw_outline(c);
     158            break;
     159        case ButtonRelease:
     160            draw_outline(c);                     /* clear */
     161            XUngrabServer(display);
     162            XUngrabPointer(display, CurrentTime);
     163            return;
     164        default:
     165            break;
    164166        }
    165167    }
     
    167169
    168170void
    169 move(Client *c, int set)
     171move(Client * c, int set)
    170172{
    171173    if (!set)
     
    178180
    179181void
    180 resize(Client *c, int set)
     182resize(Client * c, int set)
    181183{
    182184    if (!set)
     
    193195
    194196void
    195 maximise_horiz(Client *c)
     197maximise_horiz(Client * c)
    196198{
    197199    if (c->oldw) {
     
    208210
    209211void
    210 maximise_vert(Client *c)
     212maximise_vert(Client * c)
    211213{
    212214    if (c->oldh) {
     
    223225
    224226void
    225 hide(Client *c)
     227hide(Client * c)
    226228{
    227229    c->ignore_unmap = 2;
     
    232234
    233235void
    234 unhide(Client *c, int raiseit)
     236unhide(Client * c, int raiseit)
    235237{
    236238    c->ignore_unmap = 0;
    237239    XMapWindow(display, c->window);
    238     raiseit ? XMapRaised(display, c->parent) : XMapWindow(display, c->parent);
     240    raiseit ? XMapRaised(display, c->parent) : XMapWindow(display,
     241                                                          c->parent);
    239242    set_wm_state(c, NormalState);
    240243}
     
    245248
    246249void
    247 next(Client *c)
     250next(Client * c)
    248251{
    249252    Client *newc;
    250253
    251     newc = next_client_on_vdesk(( c ? c : head_client));
     254    newc = next_client_on_vdesk((c ? c : head_client));
    252255
    253256    if (!newc)
    254         return;         /* couldn't find a next on this screen */
     257        return;                                  /* couldn't find a next on this screen */
    255258
    256259    focus_client(newc, RAISE);
     
    285288
    286289void
    287 focus_client(Client *c, int raiseit)
     290focus_client(Client * c, int raiseit)
    288291{
    289292    Client *cp;
     
    305308
    306309void
    307 unfocus_client(Client *c)
     310unfocus_client(Client * c)
    308311{
    309312    XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
  • ldm/trunk/fuentes/wwm/sendkey.c

    r516 r855  
    1313
    1414void
    15 key_to_event(KeySym key, XEvent *event, Window w, int type)
     15key_to_event(KeySym key, XEvent * event, Window w, int type)
    1616{
    17     event->xkey.type    = type;
     17    event->xkey.type = type;
    1818    event->xkey.display = display;
    19     event->xkey.root    = RootWindow(display, DefaultScreen(display));
    20     event->xkey.time    = CurrentTime;
    21     event->xkey.x       = event->xkey.y = 0;
    22     event->xkey.x_root  = event->xkey.y_root = 0;
    23     event->xkey.state   = WMMODMASK;
    24     event->xkey.window  = w;
     19    event->xkey.root = RootWindow(display, DefaultScreen(display));
     20    event->xkey.time = CurrentTime;
     21    event->xkey.x = event->xkey.y = 0;
     22    event->xkey.x_root = event->xkey.y_root = 0;
     23    event->xkey.state = WMMODMASK;
     24    event->xkey.window = w;
    2525    event->xkey.keycode = XKeysymToKeycode(display, key);
    2626}
Note: See TracChangeset for help on using the changeset viewer.