Browse Source

Imported Upstream version 1.3.4

tags/upstream/1.3.6
Mateusz Łukasik 6 years ago
commit
8d3ae74a3a
47 changed files with 6568 additions and 0 deletions
  1. +174
    -0
      CMakeLists.txt
  2. +339
    -0
      COPYING
  3. +103
    -0
      ChangeLog
  4. +149
    -0
      Ck.cpp
  5. +46
    -0
      Ck.h
  6. +21
    -0
      INSTALL
  7. +275
    -0
      PAM.cpp
  8. +99
    -0
      PAM.h
  9. +59
    -0
      README
  10. +128
    -0
      THEMES
  11. +22
    -0
      TODO
  12. +1256
    -0
      app.cpp
  13. +119
    -0
      app.h
  14. +311
    -0
      cfg.cpp
  15. +56
    -0
      cfg.h
  16. +71
    -0
      cmake/modules/FONTCONFIGConfig.cmake
  17. +59
    -0
      cmake/modules/FindCkConnector.cmake
  18. +72
    -0
      cmake/modules/FindDBus.cmake
  19. +74
    -0
      cmake/modules/FindPAM.cmake
  20. +50
    -0
      const.h
  21. +896
    -0
      image.cpp
  22. +79
    -0
      image.h
  23. +102
    -0
      jpeg.c
  24. +26
    -0
      log.cpp
  25. +34
    -0
      log.h
  26. +22
    -0
      main.cpp
  27. +106
    -0
      numlock.cpp
  28. +33
    -0
      numlock.h
  29. +10
    -0
      pam.sample
  30. +642
    -0
      panel.cpp
  31. +158
    -0
      panel.h
  32. +169
    -0
      png.c
  33. +93
    -0
      slim.1
  34. +91
    -0
      slim.conf
  35. +60
    -0
      switchuser.cpp
  36. +47
    -0
      switchuser.h
  37. +1
    -0
      themes/CMakeLists.txt
  38. +5
    -0
      themes/default/CMakeLists.txt
  39. +2
    -0
      themes/default/COPYRIGHT.background
  40. +16
    -0
      themes/default/COPYRIGHT.panel
  41. +340
    -0
      themes/default/LICENSE.panel
  42. BIN
      themes/default/background.jpg
  43. BIN
      themes/default/panel.png
  44. +37
    -0
      themes/default/slim.theme
  45. +69
    -0
      util.cpp
  46. +24
    -0
      util.h
  47. +23
    -0
      xinitrc.sample

+ 174
- 0
CMakeLists.txt View File

@@ -0,0 +1,174 @@
cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)

set(PROJECT_NAME slim)
project(${PROJECT_NAME})

#Pretty colors
set(CMAKE_COLOR_MAKEFILE ON)
#Dont force verbose
set(CMAKE_VERBOSE_MAKEFILE ON)
#Include current dir
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)

INCLUDE(CheckIncludeFile)
INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckTypeSize)

# Version
set(SLIM_VERSION_MAJOR "1")
set(SLIM_VERSION_MINOR "3")
set(SLIM_VERSION_PATCH "4")
set(SLIM_VERSION "${SLIM_VERSION_MAJOR}.${SLIM_VERSION_MINOR}.${SLIM_VERSION_PATCH}")

set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
set(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/share/slim")
set(SYSCONFDIR "/etc")
set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")

set(SLIM_DEFINITIONS)
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"
)
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DNEEDS_BASENAME")
else()
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DHAVE_SHADOW")
endif()

set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPACKAGE=\"slim\"")
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DVERSION=\"${SLIM_VERSION}\"")
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DPKGDATADIR=\"${PKGDATADIR}\"")
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DSYSCONFDIR=\"${SYSCONFDIR}\"")

# Flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O2" )
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -g -O2" )

# source
set(slim_srcs
main.cpp
app.cpp
cfg.cpp
image.cpp
numlock.cpp
panel.cpp
switchuser.cpp
util.cpp
log.cpp
png.c
jpeg.c
)

if(USE_PAM)
set(slim_srcs ${slim_srcs} PAM.cpp)
endif(USE_PAM)
if(USE_CONSOLEKIT)
set(slim_srcs ${slim_srcs} Ck.cpp)
endif(USE_CONSOLEKIT)

add_executable(${PROJECT_NAME} ${slim_srcs})

#Set the custom CMake module directory where our include/lib finders are
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

find_package(X11 REQUIRED)
find_package(Freetype REQUIRED)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)

# Fontconfig
set(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
find_package(FONTCONFIG REQUIRED)
if(FONTCONFIG_FOUND)
message("\tFontConfig Found")
target_link_libraries(${PROJECT_NAME} ${FONTCONFIG_LIBRARY})
include_directories(${FONTCONFIG_INCLUDE_DIR})
endif(FONTCONFIG_FOUND)

# PAM
if(USE_PAM)
message("\tPAM Enabled")
find_package(PAM)
if(PAM_FOUND)
message("\tPAM Found")
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DUSE_PAM")
target_link_libraries(${PROJECT_NAME} ${PAM_LIBRARY})
include_directories(${PAM_INCLUDE_DIR})
else(PAM_FOUND)
message("\tPAM Not Found")
endif(PAM_FOUND)
else(USE_PAM)
message("\tPAM disabled")
endif(USE_PAM)

# ConsoleKit
if(USE_CONSOLEKIT)
find_package(CkConnector)
message("\tConsoleKit Enabled")
if(CKCONNECTOR_FOUND)
message("\tConsoleKit Found")
# DBus check
find_package(DBus REQUIRED)
if(DBUS_FOUND)
message("\tDBus Found")
target_link_libraries(${PROJECT_NAME} ${DBUS_LIBRARIES})
include_directories(${DBUS_ARCH_INCLUDE_DIR})
include_directories(${DBUS_INCLUDE_DIR})
set(SLIM_DEFINITIONS ${SLIM_DEFINITIONS} "-DUSE_CONSOLEKIT")
target_link_libraries(${PROJECT_NAME} ${CKCONNECTOR_LIBRARIES})
include_directories(${CKCONNECTOR_INCLUDE_DIR})
else(DBUS_FOUND)
message("\tDBus Not Found")
endif(DBUS_FOUND)
else(CKCONNECTOR_FOUND)
message("\tConsoleKit Not Found")
message("\tConsoleKit disabled")
endif(CKCONNECTOR_FOUND)
else(USE_CONSOLEKIT)
message("\tConsoleKit disabled")
endif(USE_CONSOLEKIT)

# system librarys
find_library(M_LIB m)
find_library(RT_LIB rt)
find_library(CRYPTO_LIB crypt)

add_definitions(${SLIM_DEFINITIONS})

#Set up include dirs with all found packages
include_directories(
${X11_INCLUDE_DIR}
${X11_Xft_INCLUDE_PATH}
${X11_Xrender_INCLUDE_PATH}
${FREETYPE_INCLUDE_DIR_freetype2}
${X11_Xmu_INCLUDE_PATH}
${ZLIB_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
)

#Set up library with all found packages
target_link_libraries(${PROJECT_NAME}
${M_LIB}
${RT_LIB}
${CRYPTO_LIB}
${X11_X11_LIB}
${X11_Xft_LIB}
${X11_Xrender_LIB}
${X11_Xmu_LIB}
${FREETYPE_LIBRARY}
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
)

####### install
# slim
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin )
# man file
install(FILES slim.1 DESTINATION ${MANDIR}/man1/)
# configure
install(FILES slim.conf DESTINATION ${SYSCONFDIR})
# themes directory
subdirs(themes)

+ 339
- 0
COPYING View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

+ 103
- 0
ChangeLog View File

@@ -0,0 +1,103 @@
1.3.4 - 2012.06.26
* Replaced stderr writes function.
* Fix numlock control.
* Fix build with GLUT.
* Fix PAM authentication.

1.3.3 - 2012.02.22
* Change build system to CMake.
* Add support ConsoleKit.
* Fix some bugs....

1.3.2 - 2010.07.08
* Add support xauth secret.
* Add xnest_debug mode.

1.3.1 - 2008.09.26
* Added focus_password config option for focusing password
automatically when default_user is enabled
* Added auto_login option
* Fixed uninitialized daemonmode, see
http://www.freebsd.org/cgi/query-pr.cgi?pr=114366
* Fixed maximum length for password
* Introduced customization options for session text:
font, colors, position, shadows.

1.3.0 - 2006.07.14
* Added PAM support by Martin Parm
* Fixed segfault on exit when testing themes. Thanks
to Darren Salt & Mike Massonnet
* Fixed vt argument detection, thanks to Henrik Brix Andersen
* Corrected reference to input_color in the default theme
* Fixed default shell setting
* Fix segfault when calling XCloseDisplay(NULL); thanks Uli Schlachter

1.2.6 - 2006.09.15
* Bug #008167: Update pid when in daemon mode
* Fixed warnings when compiling with -Wall. Thanks to
KIMURA Masaru
* Fixed major memory leaks with repeated login (bug #007535)

1.2.5 - 2006.07.24
* hiding of the cursor is now an option (disabled
by default) since some WMs does not re-initialize
the root window cursor.
* The X server is restarted when the user logs out.
This fixes potential security issues with user-launched
apps staying attached to the root window after logout.
* Bug #7432 : Added proper Xauth authentication: the X server
is started with the -auth option and the user who logs
in has his .Xauthority file initializated.

1.2.4 - 2006.01.18
* Added commands for session start and stop
(i.e. for session registering)
* Added automatic numlock on/off option
* Support for numpad Enter key
* Restored support for daemon option in the config
file.
* Lock file now uses process id, no more false
locking (thanks to Tobias Roth)

1.2.3 - 2005.09.11
* Added FreeBSD, NetBSD, OpenBSD support
* Replaced autotools with plain makefile(s)
* Added 'suspend' command (untested, we don't use it)
* Added support for %theme variable in login command
1.2.2 - 2005.05.21
* fix panel drawing on screens <= 1024x768
* Don't start X server unless valid theme found
* revert to 'default' of invalid theme specified
* try all themes from a set if one doesn't work
1.2.1 - 2005.05.17
* draw input directly on panel

1.2.0 - 2005.05.16
* added theme preview (slim -p /path/to/theme)
* added JPEG support for panel image
* added 'center' background type and 'background_color' option
* added text shadow
* added warning when execution of login command fails
* Fix login failure when no shell specified in /etc/passwd
* Print error when login command execution fails
* add XNEST_DEBUG ifdef's to allow for easy debugging
* Add support for Ctrl-u and Ctrl-w
* Add 'vt07' to server arguments if not already specified
* Removes daemon option from the config file. Use slim -d
* Allow 'current_theme' to be a set of themes, choose randomly
* Change default theme

1.1.0 - 2004.12.09
* error messages for X11 apps are no longer redirected
to the log file
* fixed text position for default theme
* added configurable shutdown and reboot messages
* separated 'Enter username' and 'Enter password' messages
position.
* due to the previous two points, the theme format has
slightly changed
1.0.0 - 2004.12.07
* First public SLiM release

+ 149
- 0
Ck.cpp View File

@@ -0,0 +1,149 @@
/* SLiM - Simple Login Manager
Copyright (C) 2011 David Hauweele

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#include <cstdio>
#include <iostream>

#include <ck-connector.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <stdarg.h>

#include "Ck.h"

namespace Ck {
Exception::Exception(const std::string &func,
const std::string &errstr):
func(func),
errstr(errstr)
{}

dbus_bool_t Session::ck_connector_open_graphic_session(const std::string &display,
uid_t uid)
{
dbus_bool_t local = true;
const char *session_type = "x11";
const char *x11_display = display.c_str();
const char *x11_device = get_x11_device(display);
const char *remote_host = "";
const char *display_dev = "";

return ck_connector_open_session_with_parameters(ckc, &error,
"unix-user", &uid,
"session-type", &session_type,
"x11-display", &x11_display,
"x11-display-device", &x11_device,
"display-device", &display_dev,
"remote-host-name", &remote_host,
"is-local", &local,
NULL);
}

const char * Session::get_x11_device(const std::string &display)
{
static char device[32];

Display *xdisplay = XOpenDisplay(display.c_str());

if(!xdisplay)
throw Exception(__func__, "cannot open display");

Window root;
Atom xfree86_vt_atom;
Atom return_type_atom;
int return_format;
unsigned long return_count;
unsigned long bytes_left;
unsigned char *return_value;
long vt;

xfree86_vt_atom = XInternAtom(xdisplay, "XFree86_VT", true);

if(xfree86_vt_atom == None)
throw Exception(__func__, "cannot get XFree86_VT");

root = DefaultRootWindow(xdisplay);

if(XGetWindowProperty(xdisplay, root, xfree86_vt_atom,
0L, 1L, false, XA_INTEGER,
&return_type_atom, &return_format,
&return_count, &bytes_left,
&return_value) != Success)
throw Exception(__func__, "cannot get root window property");

if(return_type_atom != XA_INTEGER)
throw Exception(__func__, "bad atom type");

if(return_format != 32)
throw Exception(__func__, "invalid return format");

if(return_count != 1)
throw Exception(__func__, "invalid count");

if(bytes_left != 0)
throw Exception(__func__, "invalid bytes left");

vt = *((long *)return_value);

std::snprintf(device, 32, "/dev/tty%ld", vt);

if(return_value)
XFree(return_value);

return device;
}

void Session::open_session(const std::string &display, uid_t uid)
{
ckc = ck_connector_new();

if(!ckc)
throw Exception(__func__, "error setting up connection to ConsoleKit");

if(!ck_connector_open_graphic_session(display, uid)) {
if(dbus_error_is_set(&error))
throw Exception(__func__, error.message);
else
throw Exception(__func__, "cannot open ConsoleKit session: OOM, DBus system bus "
" not available or insufficient privileges");
}
}

const char * Session::get_xdg_session_cookie()
{
return ck_connector_get_cookie(ckc);
}

void Session::close_session()
{
if(!ck_connector_close_session(ckc, &error)) {
if(dbus_error_is_set(&error))
throw Exception(__func__, error.message);
else
throw Exception(__func__, "cannot close ConsoleKit session: OOM, DBus system bus "
" not available or insufficient privileges");
}
}

Session::Session()
{
dbus_error_init(&error);
}

Session::~Session()
{
dbus_error_free(&error);
}
};

std::ostream& operator<<( std::ostream& os, const Ck::Exception& e)
{
os << e.func << ": " << e.errstr;
return os;
}

+ 46
- 0
Ck.h View File

@@ -0,0 +1,46 @@
/* SLiM - Simple Login Manager
Copyright (C) 2007 Martin Parm

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#ifndef _CK_H_
#define _CK_H_

#include <string>

#include <ck-connector.h>
#include <dbus/dbus.h>

namespace Ck {
class Exception {
public:
std::string func;
std::string errstr;
Exception(const std::string &func, const std::string &errstr);
};

class Session {
private:
CkConnector *ckc;
DBusError error;

const char * get_x11_device(const std::string &display);
dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
uid_t uid);
public:
const char * get_xdg_session_cookie();
void open_session(const std::string &display, uid_t uid);
void close_session();

Session();
~Session();
};
};

std::ostream& operator<<( std::ostream& os, const Ck::Exception& e);

#endif /* _CK_H_ */

+ 21
- 0
INSTALL View File

@@ -0,0 +1,21 @@
INSTALL file for SLiM

0. Prerequisites:
- cmake
- X.org or XFree86
- libxmu
- libpng
- libjpeg

1. to build and install the program:
- edit the Makefile to adjust libraries and paths to your OS (if needed)
- mkdir build ; cd build ; cmake ..
or
- mkdir build ; cd build ; cmake .. -DUSE_PAM=yes to enable PAM support
or
- mkdir build ; cd build ; cmake .. -DUSE_CONSOLEKIT=yes
to enable CONSOLEKIT support
- make && make install
2. automatic startup
Edit the init scripts according to your OS/Distribution.

+ 275
- 0
PAM.cpp View File

@@ -0,0 +1,275 @@
/* SLiM - Simple Login Manager
Copyright (C) 2007 Martin Parm

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
#include <string>
#include <iostream>
#include "PAM.h"

namespace PAM {
Exception::Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
errnum(_errnum),
errstr(pam_strerror(_pam_handle, _errnum)),
func_name(_func_name)
{}

Exception::~Exception(void){}

Auth_Exception::Auth_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
Exception(_pam_handle, _func_name, _errnum){}

Cred_Exception::Cred_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
Exception(_pam_handle, _func_name, _errnum){}

int Authenticator::_end(void){
int result=pam_end(pam_handle, last_result);
pam_handle=0;
return result;
}

Authenticator::Authenticator(conversation* conv, void* data):
pam_handle(0),
last_result(PAM_SUCCESS)
{
pam_conversation.conv=conv;
pam_conversation.appdata_ptr=data;
}

Authenticator::~Authenticator(void){
if (pam_handle) _end();
}

void Authenticator::start(const std::string& service){
switch((last_result=pam_start(service.c_str(), NULL, &pam_conversation, &pam_handle))){
default:
throw Exception(pam_handle, "pam_start()", last_result);

case PAM_SUCCESS:
break;
}
return;
}

void Authenticator::end(void){
switch((last_result=_end())){
default:
throw Exception(pam_handle, "pam_end()", last_result);

case PAM_SUCCESS:
break;

}
return;
}

void Authenticator::set_item(const Authenticator::ItemType item, const void* value){
switch((last_result=pam_set_item(pam_handle, item, value))){
default:
_end();
throw Exception(pam_handle, "pam_set_item()", last_result);

case PAM_SUCCESS:
break;
}
return;
}

const void* Authenticator::get_item(const Authenticator::ItemType item){
const void* data;
switch ((last_result=pam_get_item(pam_handle, item, &data))){
default:
case PAM_SYSTEM_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_get_item()", last_result);

case PAM_PERM_DENIED: // The value of item was NULL
case PAM_SUCCESS:
break;
}
return data;
}

#ifdef __LIBPAM_VERSION
void Authenticator::fail_delay(const unsigned int micro_sec){
switch((last_result=pam_fail_delay(pam_handle, micro_sec))){
default:
_end();
throw Exception(pam_handle, "fail_delay()", last_result);

case PAM_SUCCESS:
break;
}
return;
}
#endif

void Authenticator::authenticate(void){
switch((last_result=pam_authenticate(pam_handle, 0))){
default:
case PAM_ABORT:
case PAM_AUTHINFO_UNAVAIL:
_end();
throw Exception(pam_handle, "pam_authenticate()", last_result);

case PAM_USER_UNKNOWN:
case PAM_MAXTRIES:
case PAM_CRED_INSUFFICIENT:
case PAM_AUTH_ERR:
throw Auth_Exception(pam_handle, "pam_authentication()", last_result);

case PAM_SUCCESS:
break;
}

switch((last_result=pam_acct_mgmt(pam_handle, PAM_SILENT))){
// The documentation and implementation of Linux PAM differs:
// PAM_NEW_AUTHTOKEN_REQD is described in the documentation but
// don't exists in the actual implementation. This issue needs
// to be fixes at some point.

default:
//case PAM_NEW_AUTHTOKEN_REQD:
case PAM_ACCT_EXPIRED:
case PAM_USER_UNKNOWN:
_end();
throw Exception(pam_handle, "pam_acct_mgmt()", last_result);
case PAM_AUTH_ERR:
case PAM_PERM_DENIED:
throw Auth_Exception(pam_handle, "pam_acct_mgmt()", last_result);

case PAM_SUCCESS:
break;
};
return;
}

void Authenticator::open_session(void){
switch((last_result=pam_setcred(pam_handle, PAM_ESTABLISH_CRED))){
default:
case PAM_CRED_ERR:
case PAM_CRED_UNAVAIL:
_end();
throw Exception(pam_handle, "pam_setcred()", last_result);

case PAM_CRED_EXPIRED:
case PAM_USER_UNKNOWN:
throw Cred_Exception(pam_handle, "pam_setcred()", last_result);

case PAM_SUCCESS:
break;
}

switch((last_result=pam_open_session(pam_handle, 0))){
// The documentation and implementation of Linux PAM differs:
// PAM_SESSION_ERROR is described in the documentation but
// don't exists in the actual implementation. This issue needs
// to be fixes at some point.

default:
//case PAM_SESSION_ERROR:
pam_setcred(pam_handle, PAM_DELETE_CRED);
_end();
throw Exception(pam_handle, "pam_open_session()", last_result);

case PAM_SUCCESS:
break;
};
return;
}

void Authenticator::close_session(void){
switch((last_result=pam_close_session(pam_handle, 0))){
// The documentation and implementation of Linux PAM differs:
// PAM_SESSION_ERROR is described in the documentation but
// don't exists in the actual implementation. This issue needs
// to be fixes at some point.

default:
//case PAM_SESSION_ERROR:
pam_setcred(pam_handle, PAM_DELETE_CRED);
_end();
throw Exception(pam_handle, "pam_close_session", last_result);

case PAM_SUCCESS:
break;
};
switch((last_result=pam_setcred(pam_handle, PAM_DELETE_CRED))){
default:
case PAM_CRED_ERR:
case PAM_CRED_UNAVAIL:
case PAM_CRED_EXPIRED:
case PAM_USER_UNKNOWN:
_end();
throw Exception(pam_handle, "pam_setcred()", last_result);

case PAM_SUCCESS:
break;
}
return;
}

void Authenticator::setenv(const std::string& key, const std::string& value){
std::string name_value = key+"="+value;
switch((last_result=pam_putenv(pam_handle, name_value.c_str()))){
default:
case PAM_PERM_DENIED:
case PAM_ABORT:
case PAM_BUF_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_putenv()", last_result);

case PAM_SUCCESS:
break;
};
return;
}

void Authenticator::delenv(const std::string& key){
switch((last_result=pam_putenv(pam_handle, key.c_str()))){
default:
case PAM_PERM_DENIED:
case PAM_ABORT:
case PAM_BUF_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_putenv()", last_result);

case PAM_SUCCESS:
break;
};
return;
}

const char* Authenticator::getenv(const std::string& key){
return pam_getenv(pam_handle, key.c_str());
}

char** Authenticator::getenvlist(void){
return pam_getenvlist(pam_handle);
}

};

std::ostream& operator<<( std::ostream& os, const PAM::Exception& e){
os << e.func_name << ": " << e.errstr;
return os;
}

+ 99
- 0
PAM.h View File

@@ -0,0 +1,99 @@
/* SLiM - Simple Login Manager
Copyright (C) 2007 Martin Parm

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#ifndef _PAM_H_
#define _PAM_H_
#include <string>
#include <security/pam_appl.h>

#ifdef __LIBPAM_VERSION
#include <security/pam_misc.h>
#endif

namespace PAM {
class Exception{
public:
int errnum;
std::string errstr;
std::string func_name;
Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
virtual ~Exception(void);
};

class Auth_Exception: public Exception{
public:
Auth_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
};

class Cred_Exception: public Exception{
public:
Cred_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
};


class Authenticator{
private:
struct pam_conv pam_conversation;
pam_handle_t* pam_handle;
int last_result;

int _end(void);
public:
typedef int (conversation)(int num_msg,
const struct pam_message **msg,
struct pam_response **resp,
void *appdata_ptr);

enum ItemType {
Service = PAM_SERVICE,
User = PAM_USER,
User_Prompt = PAM_USER_PROMPT,
TTY = PAM_TTY,
Requestor = PAM_RUSER,
Host = PAM_RHOST,
Conv = PAM_CONV,
#ifdef __LIBPAM_VERSION
//Fail_Delay = PAM_FAIL_DELAY
#endif
};

public:
Authenticator(conversation* conv, void* data=0);
~Authenticator(void);
void start(const std::string& service);
void end(void);
void set_item(const ItemType item, const void* value);
const void* get_item(const ItemType item);
#ifdef __LIBPAM_VERSION
void fail_delay(const unsigned int micro_sec);
#endif
void authenticate(void);
void open_session(void);
void close_session(void);
void setenv(const std::string& key, const std::string& value);
void delenv(const std::string& key);
const char* getenv(const std::string& key);
char** getenvlist(void);

private:
// Explicitly disable copy constructor and copy assignment
Authenticator(const PAM::Authenticator&);
Authenticator& operator=(const PAM::Authenticator&);
};
};

std::ostream& operator<<( std::ostream& os, const PAM::Exception& e);
#endif

+ 59
- 0
README View File

@@ -0,0 +1,59 @@
README file for SLiM

Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

INTRODUCTION
SLiM (Simple Login Manager) is a graphical login manager for X11.
It aims to be simple, fast and independent from the various
desktop environments.
SLiM is based on latest stable release of Login.app by Per Lidén.

New features:
- External themes and configuration
- PNG support with alpha transparency for panel
- PNG / JPEG support for backgrounds
- XFT / freetype support
- Double or single (GDM-style) inputbox support
- CMake build procedure

INSTALLATION
see the INSTALL file
USAGE

To launch slim, execute run the slim binary,
followed by the -d option if you want it to
run as a daemon in the background (reccommended)
enter username and password to login. The ~/.xinitrc
file is executed by default, so be sure to have a working
.xinitrc file in your home.
Special usernames (commands configurable in the config file):
- console: start console login
- exit: exit SLiM
- halt: halt the system
- reboot: reboot the system
pressing the F11 key executes a user-specified
command (see the configuration file), the default
is to take a screenshot if the 'import' program is available.
CONFIGURATION
/usr/etc/slim.conf is the main configuration file.
Options are explained in the file itself
THEMES
See THEMES

COPYRIGHT
SLiM is copyright (c) 2004-06 by Simone Rota, Johannes Winkelmann,
Nobuhiro Iwamatsu and is available under the GNU General Public
License.
See the COPYING file for the complete license.

Image handling code adapted and extended from xplanet 1.0.1,
copyright (c) 2002-04 by Hari Nair

Login.app is copyright (c) 1997, 1998 by Per Liden and is
licensed through the GNU General Public License.

+ 128
- 0
THEMES View File

@@ -0,0 +1,128 @@
Quick THEME howto for SLiM

Some basic information regarding the slim theme format.
Read this file if you plan to make some theme for
the program, and of course have a look at the included themes

GENERAL CONCEPT
A SLiM theme essentially consists of:
- a background image (background.png or background.jpg)
- a panel image (panel.png or panel.jpg)
- input box(es) and messages and their placement
and properties (slim.theme)
The panel and background images can be a PNG or JPEG file.
The panel is blended into the background image,
taking care of alpha transparency.

SUPPORTED FORMATS
- fonts: use the xft font specs, ie: Verdana:size=16:bold
- colors: use html hex format, ie #0066CC
- positions: can be either absolute in pixels, ie 350
or relative to the container, ie 50% is in the middle
of the screen.
OPTIONS
The following is an example slim.theme file
----------------------------------------------------------------------
# Color, font, position for the messages (ie: shutting down)
msg_color #FFFFFF
msg_font Verdana:size=16:bold
msg_x 50%
msg_y 30

# Color, font, position for the session list
session_color #FFFFFF
session_font Verdana:size=16:bold
session_x 50%
session_y 90%

# style of background: 'stretch', 'tile', 'center', 'color'
background_style stretch
background_color #FF0033

# Horizonatal and vertical position for the panel.
input_panel_x 50%
input_panel_y 40%
# input controls horizontal and vertical positions.
# IMPORTANT! set input_pass_x and input_pass_y to -1
# to use a single input box for username/password (GDM Style).
# Note that this fields only accept absolute values.
input_name_x 40
input_name_y 100
input_pass_x 40
input_pass_y 120
# Input controls font and color
input_font Verdana:size=12
input_color #000000

# Welcome message position. (relative to the panel)
# use -1 for both values or comment the options to disable
# the welcome message
welcome_x 50%
welcome_y 38
# Font and color for the welcome message
welcome_font Verdana:size=16:bold:slant=italic
welcome_color #d7dde8

# 'Enter username' font and foreground/background color
username_font Verdana:size=12
username_color #d7dde8

# 'Enter username' and 'Enter password' position (relative to the panel)
# use -1 for both values to disable the message
# note that in case of single inputbox the password values are ignored.
username_x 50%
username_y 146
password_x 50%
password_y 146

# The message to be displayed. Leave blank if no message
# is needed (ie, when already present in the panel image)
username_msg Please enter your username
password_msg Please enter your password
----------------------------------------------------------------------

SHADOWS

The 'msg', 'input', 'welcome', 'session' and 'username' sections
support shadows; three values can be configured:
- color: the shadow color
- x offset: the offset in x direction, relative to the normal text
- y offset: the offset in y direction, relative to the normal text

So to add a text shadow to the welcome message, add the following
to slim.conf:
----------------------------------------------------------------------
welcome_shadow_xoffset -2
welcome_shadow_yoffset 2
welcome_shadow_color #ff0000
----------------------------------------------------------------------
The other keys are analogue:
----------------------------------------------------------------------
# for username and password label
username_shadow_xoffset 2
username_shadow_yoffset -2
username_shadow_color #ff0000

# for the input fields
input_shadow_xoffset 1
input_shadow_yoffset 1
input_shadow_color #0000ff

# for the messages:
msg_shadow_xoffset 1
msg_shadow_yoffset 1
msg_shadow_color #ff00ff

# For the session:
session_shadow_xoffset 1
session_shadow_yoffset 1
session_shadow_color #ff00ff
----------------------------------------------------------------------


+ 22
- 0
TODO View File

@@ -0,0 +1,22 @@
1.2.2
-----
- drawing problem on screens <= 1024x768 (implemented)
- Don't start X server if theme's not found

1.2.x
-----
- i18n
- don't choose a non-existing theme in random selection
- think about multi-line configuration:
current_theme = t1, t2, t3
current_theme = t4, t5
or
current_theme = t1, t2, t3 \
t4, t5
- FreeBSD fixes

2.0.x
-----
- restart X server on ctrl-alt-backspace
- allow switching theme on the fly if a set is specified in slim.conf
- text alignment, to allow to center texts of unknown length (e.g. %host)

+ 1256
- 0
app.cpp
File diff suppressed because it is too large
View File


+ 119
- 0
app.h View File

@@ -0,0 +1,119 @@
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#ifndef _APP_H_
#define _APP_H_

#include <X11/Xlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <setjmp.h>
#include <stdlib.h>
#include <iostream>
#include "panel.h"
#include "cfg.h"
#include "image.h"

#ifdef USE_PAM
#include "PAM.h"
#endif
#ifdef USE_CONSOLEKIT
#include "Ck.h"
#endif

class App {
public:
App(int argc, char** argv);
~App();
void Run();
int GetServerPID();
void RestartServer();
void StopServer();

// Lock functions
void GetLock();
void RemoveLock();

bool isServerStarted();

private:
void Login();
void Reboot();
void Halt();
void Suspend();
void Console();
void Exit();
void KillAllClients(Bool top);
void ReadConfig();
void OpenLog();
void CloseLog();
void HideCursor();
void CreateServerAuth();
char* StrConcat(const char* str1, const char* str2);
void UpdatePid();

bool AuthenticateUser(bool focuspass);
static std::string findValidRandomTheme(const std::string& set);
static void replaceVariables(std::string& input,
const std::string& var,
const std::string& value);

// Server functions
int StartServer();
int ServerTimeout(int timeout, char *string);
int WaitForServer();

// Private data
Window Root;
Display* Dpy;
int Scr;
Panel* LoginPanel;
int ServerPID;
const char* DisplayName;
bool serverStarted;

#ifdef USE_PAM
PAM::Authenticator pam;
#endif
#ifdef USE_CONSOLEKIT
Ck::Session ck;
#endif

// Options
char* DispName;

Cfg *cfg;

Pixmap BackgroundPixmap;

void blankScreen();
Image* image;
void setBackground(const std::string& themedir);

bool firstlogin;
bool daemonmode;
bool force_nodaemon;
// For testing themes
char* testtheme;
bool testing;
std::string themeName;
std::string mcookie;

const int mcookiesize;
};


#endif


+ 311
- 0
cfg.cpp View File

@@ -0,0 +1,311 @@
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#include <fstream>
#include <string>
#include <iostream>
#include <unistd.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>

#include "cfg.h"

using namespace std;

typedef pair<string,string> option;

Cfg::Cfg()
: currentSession(-1)
{
// Configuration options
options.insert(option("default_path","/bin:/usr/bin:/usr/local/bin"));
options.insert(option("default_xserver","/usr/bin/X"));
options.insert(option("xserver_arguments",""));
options.insert(option("numlock",""));
options.insert(option("daemon",""));
options.insert(option("xauth_path","/usr/bin/xauth"));
options.insert(option("login_cmd","exec /bin/bash -login ~/.xinitrc %session"));
options.insert(option("halt_cmd","/sbin/shutdown -h now"));
options.insert(option("reboot_cmd","/sbin/shutdown -r now"));
options.insert(option("suspend_cmd",""));
options.insert(option("sessionstart_cmd",""));
options.insert(option("sessionstop_cmd",""));
options.insert(option("console_cmd","/usr/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
options.insert(option("screenshot_cmd","import -window root /slim.png"));
options.insert(option("welcome_msg","Welcome to %host"));
options.insert(option("session_msg","Session:"));
options.insert(option("default_user",""));
options.insert(option("focus_password","no"));
options.insert(option("auto_login","no"));
options.insert(option("current_theme","default"));
options.insert(option("lockfile","/var/run/slim.lock"));
options.insert(option("logfile","/var/log/slim.log"));
options.insert(option("authfile","/var/run/slim.auth"));
options.insert(option("shutdown_msg","The system is halting..."));
options.insert(option("reboot_msg","The system is rebooting..."));
options.insert(option("sessions","wmaker,blackbox,icewm"));
options.insert(option("sessiondir",""));
options.insert(option("hidecursor","false"));

// Theme stuff
options.insert(option("input_panel_x","50%"));
options.insert(option("input_panel_y","40%"));
options.insert(option("input_name_x","200"));
options.insert(option("input_name_y","154"));
options.insert(option("input_pass_x","-1")); // default is single inputbox
options.insert(option("input_pass_y","-1"));
options.insert(option("input_font","Verdana:size=11"));
options.insert(option("input_color", "#000000"));
options.insert(option("input_cursor_height","20"));
options.insert(option("input_maxlength_name","20"));
options.insert(option("input_maxlength_passwd","20"));
options.insert(option("input_shadow_xoffset", "0"));
options.insert(option("input_shadow_yoffset", "0"));
options.insert(option("input_shadow_color","#FFFFFF"));

options.insert(option("welcome_font","Verdana:size=14"));
options.insert(option("welcome_color","#FFFFFF"));
options.insert(option("welcome_x","-1"));
options.insert(option("welcome_y","-1"));
options.insert(option("welcome_shadow_xoffset", "0"));
options.insert(option("welcome_shadow_yoffset", "0"));
options.insert(option("welcome_shadow_color","#FFFFFF"));

options.insert(option("intro_msg",""));
options.insert(option("intro_font","Verdana:size=14"));
options.insert(option("intro_color","#FFFFFF"));
options.insert(option("intro_x","-1"));
options.insert(option("intro_y","-1"));

options.insert(option("background_style","stretch"));
options.insert(option("background_color","#CCCCCC"));

options.insert(option("username_font","Verdana:size=12"));
options.insert(option("username_color","#FFFFFF"));
options.insert(option("username_x","-1"));
options.insert(option("username_y","-1"));
options.insert(option("username_msg","Please enter your username"));
options.insert(option("username_shadow_xoffset", "0"));
options.insert(option("username_shadow_yoffset", "0"));
options.insert(option("username_shadow_color","#FFFFFF"));

options.insert(option("password_x","-1"));
options.insert(option("password_y","-1"));
options.insert(option("password_msg","Please enter your password"));

options.insert(option("msg_color","#FFFFFF"));
options.insert(option("msg_font","Verdana:size=16:bold"));
options.insert(option("msg_x","40"));
options.insert(option("msg_y","40"));
options.insert(option("msg_shadow_xoffset", "0"));
options.insert(option("msg_shadow_yoffset", "0"));
options.insert(option("msg_shadow_color","#FFFFFF"));

options.insert(option("session_color","#FFFFFF"));
options.insert(option("session_font","Verdana:size=16:bold"));
options.insert(option("session_x","50%"));
options.insert(option("session_y","90%"));
options.insert(option("session_shadow_xoffset", "0"));
options.insert(option("session_shadow_yoffset", "0"));
options.insert(option("session_shadow_color","#FFFFFF"));

error = "";

}

Cfg::~Cfg() {
options.clear();
}
/*
* Creates the Cfg object and parses
* known options from the given configfile / themefile
*/
bool Cfg::readConf(string configfile) {
int n = -1;
string line, fn(configfile);
map<string,string>::iterator it;
string op;
ifstream cfgfile( fn.c_str() );
if (cfgfile) {
while (getline( cfgfile, line )) {
it = options.begin();
while (it != options.end()) {
op = it->first;
n = line.find(op);
if (n == 0)
options[op] = parseOption(line, op);
it++;
}
}
cfgfile.close();

fillSessionList();

return true;
} else {
error = "Cannot read configuration file: " + configfile;
return false;
}
}

/* Returns the option value, trimmed */
string Cfg::parseOption(string line, string option ) {
return Trim( line.substr(option.size(), line.size() - option.size()));
}


const string& Cfg::getError() const {
return error;
}

string& Cfg::getOption(string option) {
return options[option];
}

/* return a trimmed string */
string Cfg::Trim( const string& s ) {
if ( s.empty() ) {
return s;
}
int pos = 0;
string line = s;
int len = line.length();
while ( pos < len && isspace( line[pos] ) ) {
++pos;
}
line.erase( 0, pos );
pos = line.length()-1;
while ( pos > -1 && isspace( line[pos] ) ) {
--pos;
}
if ( pos != -1 ) {
line.erase( pos+1 );
}
return line;
}

/* Return the welcome message with replaced vars */
string Cfg::getWelcomeMessage(){
string s = getOption("welcome_msg");
int n = -1;
n = s.find("%host");
if (n >= 0) {
string tmp = s.substr(0, n);
char host[40];
gethostname(host,40);
tmp = tmp + host;
tmp = tmp + s.substr(n+5, s.size() - n);
s = tmp;
}
n = s.find("%domain");
if (n >= 0) {
string tmp = s.substr(0, n);;
char domain[40];
getdomainname(domain,40);
tmp = tmp + domain;
tmp = tmp + s.substr(n+7, s.size() - n);
s = tmp;
}
return s;
}

int Cfg::string2int(const char* string, bool* ok) {
char* err = 0;
int l = (int)strtol(string, &err, 10);
if (ok) {
*ok = (*err == 0);
}
return (*err == 0) ? l : 0;
}

int Cfg::getIntOption(std::string option) {
return string2int(options[option].c_str());
}

// Get absolute position
int Cfg::absolutepos(const string& position, int max, int width) {
int n = -1;
n = position.find("%");
if (n>0) { // X Position expressed in percentage
int result = (max*string2int(position.substr(0, n).c_str())/100) - (width / 2);
return result < 0 ? 0 : result ;
} else { // Absolute X position
return string2int(position.c_str());
}
}

// split a comma separated string into a vector of strings
void Cfg::split(vector<string>& v, const string& str, char c, bool useEmpty) {
v.clear();
string::const_iterator s = str.begin();
string tmp;
while (true) {
string::const_iterator begin = s;
while (*s != c && s != str.end()) { ++s; }
tmp = string(begin, s);
if (useEmpty || tmp.size() > 0)
v.push_back(tmp);
if (s == str.end()) {
break;
}
if (++s == str.end()) {
if (useEmpty)
v.push_back("");
break;
}
}
}

void Cfg::fillSessionList(){
string strSessionList = getOption("sessions");
string strSessionDir = getOption("sessiondir");

sessions.clear();

if( !strSessionDir.empty() ) {
DIR *pDir = opendir(strSessionDir.c_str());

if (pDir != NULL) {
struct dirent *pDirent = NULL;

while ((pDirent = readdir(pDir)) != NULL) {
string strFile(strSessionDir);
strFile += "/";
strFile += pDirent->d_name;

struct stat oFileStat;

if (stat(strFile.c_str( ), &oFileStat) == 0){
if (S_ISREG(oFileStat.st_mode) &&
access(strFile.c_str(), R_OK | X_OK) == 0){
sessions.push_back(string(pDirent->d_name));
}
}
}
closedir(pDir);
}
}

if (sessions.empty()){
split(sessions, strSessionList, ',', false);
}
}

string Cfg::nextSession(string current) {
if (sessions.size() < 1)
return current;

currentSession = (currentSession + 1) % sessions.size();
return sessions[currentSession];
}

+ 56
- 0
cfg.h View File

@@ -0,0 +1,56 @@
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#ifndef _CFG_H_
#define _CFG_H_

#include <string>
#include <map>
#include <vector>

#define INPUT_MAXLENGTH_NAME 30
#define INPUT_MAXLENGTH_PASSWD 50

#define CFGFILE SYSCONFDIR"/slim.conf"
#define THEMESDIR PKGDATADIR"/themes"
#define THEMESFILE "/slim.theme"

class Cfg {

public:
Cfg();
~Cfg();
bool readConf(std::string configfile);
std::string parseOption(std::string line, std::string option);
const std::string& getError() const;
std::string& getOption(std::string option);
int getIntOption(std::string option);
std::string getWelcomeMessage();

static int absolutepos(const std::string& position, int max, int width);
static int string2int(const char* string, bool* ok = 0);
static void split(std::vector<std::string>& v, const std::string& str,
char c, bool useEmpty=true);
static std::string Trim(const std::string& s);

std::string nextSession(std::string current);

private:
void fillSessionList();

private:
std::map<std::string,std::string> options;
std::vector<std::string> sessions;
int currentSession;
std::string error;

};

#endif

+ 71
- 0
cmake/modules/FONTCONFIGConfig.cmake View File

@@ -0,0 +1,71 @@
#
# Find the native FONTCONFIG includes and library
#

# This module defines
# FONTCONFIG_INCLUDE_DIR, where to find art*.h etc
# FONTCONFIG_LIBRARY, the libraries to link against to use FONTCONFIG.
# FONTCONFIG_FOUND, If false, do not try to use FONTCONFIG.
# LIBFONTCONFIG_LIBS, link information
# LIBFONTCONFIG_CFLAGS, cflags for include information

IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
INCLUDE(UsePkgConfig)
PKGCONFIG(fontconfig _fontconfigIncDir _fontconfigLinkDir _fontconfigLinkFlags _fontconfigCflags)
SET(FONTCONFIG_LIBS ${_fontconfigCflags})
ELSE (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)
INCLUDE(FindPkgConfig)
pkg_search_module(FONTCONFIG REQUIRED fontconfig)
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.5)

#INCLUDE(UsePkgConfig)

# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#PKGCONFIG(fontconfig _fontconfigIncDir _fontconfigLinkDir _fontconfigLinkFlags _fontconfigCflags)

#SET(FONTCONFIG_LIBS ${_fontconfigCflags})

IF(BUILD_OSX_BUNDLE)
FIND_PATH(FONTCONFIG_INCLUDE_DIR
NAMES fontconfig/fontconfig.h
PATHS ${FONTCONFIG_INCLUDE_DIRS} /opt/local/include
NO_DEFAULT_PATH
)
FIND_LIBRARY(FONTCONFIG_LIBRARY
NAMES fontconfig
PATHS ${FONTCONFIG_LIBRARY_DIRS} /opt/local/lib
NO_DEFAULT_PATH
)
ELSE(BUILD_OSX_BUNDLE)
FIND_PATH(FONTCONFIG_INCLUDE_DIR
NAMES fontconfig/fontconfig.h
PATHS ${FONTCONFIG_INCLUDE_DIRS}
${_fontconfigIncDir}
/usr/include
/usr/local/include
PATH_SUFFIXES fontconfig
)
# quick hack as the above finds it nicely but our source includes the libart_lgpl text at the moment
#STRING(REGEX REPLACE "/libart_lgpl" "" FONTCONFIG_INCLUDE_DIR ${FONTCONFIG_INCLUDE_DIR})
FIND_LIBRARY(FONTCONFIG_LIBRARY NAMES fontconfig
PATHS ${FONTCONFIG_LIBRARY_DIRS} /usr/lib /usr/local/lib
)
ENDIF(BUILD_OSX_BUNDLE)


# MESSAGE(STATUS "fclib ${FONTCONFIG_LIBRARY}")
# MESSAGE(STATUS "fcinclude ${FONTCONFIG_INCLUDE_DIR}")


IF (FONTCONFIG_LIBRARY)
IF (FONTCONFIG_INCLUDE_DIR)
SET( FONTCONFIG_FOUND "YES" )
SET( FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY} )
FIND_PROGRAM(FONTCONFIG_CONFIG NAMES fontconfig-config PATHS ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin)
# EXEC_PROGRAM(${FONTCONFIG_CONFIG} ARGS --libs OUTPUT_VARIABLE FONTCONFIG_LIBS)
# EXEC_PROGRAM(${FONTCONFIG_CONFIG} ARGS --cflags OUTPUT_VARIABLE FONTCONFIG_CFLAGS)
# MESSAGE(STATUS ${FONTCONFIG_LIBS})
# MESSAGE(STATUS ${FONTCONFIG_CFLAGS})
ENDIF (FONTCONFIG_INCLUDE_DIR)
ENDIF (FONTCONFIG_LIBRARY)

+ 59
- 0
cmake/modules/FindCkConnector.cmake View File

@@ -0,0 +1,59 @@
# - Try to find the ConsoleKit connector library (libck-connector)
# Once done this will define
#
# CKCONNECTOR_FOUND - system has the CK Connector
# CKCONNECTOR_INCLUDE_DIR - the CK Connector include directory
# CKCONNECTOR_LIBRARIES - the libraries needed to use CK Connector

# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at>
# modeled after FindLibArt.cmake:
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


if (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)

# in cache already
SET(CKCONNECTOR_FOUND TRUE)

else (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)

IF (NOT WIN32)
FIND_PACKAGE(PkgConfig)
IF (PKG_CONFIG_FOUND)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
pkg_check_modules(_CKCONNECTOR_PC QUIET ck-connector)
ENDIF (PKG_CONFIG_FOUND)
ENDIF (NOT WIN32)

FIND_PATH(CKCONNECTOR_INCLUDE_DIR ck-connector.h
${_CKCONNECTOR_PC_INCLUDE_DIRS}
)

FIND_LIBRARY(CKCONNECTOR_LIBRARIES NAMES ck-connector
PATHS
${_CKCONNECTOR_PC_LIBDIR}
)


if (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)
set(CKCONNECTOR_FOUND TRUE)
endif (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)


if (CKCONNECTOR_FOUND)
if (NOT CkConnector_FIND_QUIETLY)
message(STATUS "Found ck-connector: ${CKCONNECTOR_LIBRARIES}")
endif (NOT CkConnector_FIND_QUIETLY)
else (CKCONNECTOR_FOUND)
if (CkConnector_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find ck-connector")
endif (CkConnector_FIND_REQUIRED)
endif (CKCONNECTOR_FOUND)

MARK_AS_ADVANCED(CKCONNECTOR_INCLUDE_DIR CKCONNECTOR_LIBRARIES)

endif (CKCONNECTOR_INCLUDE_DIR AND CKCONNECTOR_LIBRARIES)

+ 72
- 0
cmake/modules/FindDBus.cmake View File

@@ -0,0 +1,72 @@
# - Try to find the low-level D-Bus library
# Once done this will define
#
# DBUS_FOUND - system has D-Bus
# DBUS_INCLUDE_DIR - the D-Bus include directory
# DBUS_ARCH_INCLUDE_DIR - the D-Bus architecture-specific include directory
# DBUS_LIBRARIES - the libraries needed to use D-Bus

# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at>
# modeled after FindLibArt.cmake:
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)

# in cache already
SET(DBUS_FOUND TRUE)

else (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)

IF (NOT WIN32)
FIND_PACKAGE(PkgConfig)
IF (PKG_CONFIG_FOUND)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
pkg_check_modules(_DBUS_PC QUIET dbus-1)
ENDIF (PKG_CONFIG_FOUND)
ENDIF (NOT WIN32)

FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h
${_DBUS_PC_INCLUDE_DIRS}
/usr/include
/usr/include/dbus-1.0
/usr/local/include
)

FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
${_DBUS_PC_INCLUDE_DIRS}
/usr/lib${LIB_SUFFIX}/include
/usr/lib${LIB_SUFFIX}/dbus-1.0/include
/usr/lib64/include
/usr/lib64/dbus-1.0/include
/usr/lib/include
/usr/lib/dbus-1.0/include
)

FIND_LIBRARY(DBUS_LIBRARIES NAMES dbus-1 dbus