Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@

include config.mk

SRC = instantlock.c ${COMPATSRC}
SRC = instantlock.c dbusadapter.c ${COMPATSRC}
OBJ = ${SRC:.c=.o}

all: options instantlock

options:
@echo instantlock build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "CPPFLAGS = ${CPPFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"

.c.o:
@echo CC $<
@${CC} -c ${CFLAGS} $<

${OBJ}: config.h config.mk arg.h util.h
${OBJ}: config.h config.mk lock.h util.h

config.h:
@echo creating $@ from config.def.h
Expand All @@ -36,7 +37,7 @@ dist: clean
@echo creating dist tarball
@mkdir -p instantlock-${VERSION}
@cp -R LICENSE Makefile README instantlock.1 config.mk \
${SRC} explicit_bzero.c config.def.h arg.h util.h instantlock-${VERSION}
${SRC} explicit_bzero.c config.def.h lock.h util.h instantlock-${VERSION}
@tar -cf instantlock-${VERSION}.tar instantlock-${VERSION}
@gzip instantlock-${VERSION}.tar
@rm -rf instantlock-${VERSION}
Expand All @@ -54,11 +55,19 @@ install: all
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
@sed "s/VERSION/${VERSION}/g" <instantlock.1 >${DESTDIR}${MANPREFIX}/man1/instantlock.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/instantlock.1
@echo installing dbus service, interface and config
@install -Dm 644 dbus/org.instantos.instantlock.service ${DESTDIR}${DBUS_SERVICES_INSTALL_DIR}/org.instantos.instantlock.service
@install -Dm 644 dbus/org.instantos.instantLOCK.xml ${DESTDIR}${DBUS_INTERFACES_INSTALL_DIR}/org.instantos.instantLOCK.xml
@install -Dm 644 dbus/instantlock-dbus.conf ${DESTDIR}${DBUS_CONFIG_INSTALL_DIR}/instantlock-dbus.conf

uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
@rm -f ${DESTDIR}${PREFIX}/bin/instantlock
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
@rm -f ${DESTDIR}${MANPREFIX}/man1/instantlock.1
@echo uninstalling dbus service and interface from ${DESTDIR}${DBUS_SERVICES_INSTALL_DIR}
@rm -f ${DESTDIR}${DBUS_SERVICES_INSTALL_DIR}/org.instantos.instantlock.service
@rm -f ${DESTDIR}${DBUS_INTERFACES_INSTALL_DIR}/org.instantos.instantLOCK.xml
@rm -f ${DESTDIR}${DBUS_CONFIG_INSTALL_DIR}/instantlock-dbus.conf

.PHONY: all options clean dist install uninstall
65 changes: 0 additions & 65 deletions arg.h

This file was deleted.

7 changes: 6 additions & 1 deletion config.def.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef CONFIG_DEF_H
#define CONFIG_DEF_H

/* user and group to drop privileges to */
static const char *user = "nobody";
static const char *group = "nobody";
Expand All @@ -22,4 +25,6 @@ static int onebutton = 0;
static const char * text_color = "#ffffff";

/* text size (must be a valid size) */
static const char * font_name = "10x20";
static const char * font_name = "10x20";

#endif //CONFIG_DEF_H
11 changes: 9 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ VERSION = 1.4
# paths
PREFIX = /usr
MANPREFIX = ${PREFIX}/share/man
DBUS_SERVICES_INSTALL_DIR = ${PREFIX}/share/dbus-1/services
DBUS_INTERFACES_INSTALL_DIR = ${PREFIX}/share/dbus-1/interfaces
DBUS_CONFIG_INSTALL_DIR = ${PREFIX}/etc/dbus-1/system.d
ARGTABLE3_INCLUDE_DIR = ${PREFIX}/usr/include
ARGTABLE3_LIB_DIR = ${PREFIX}/usr/lib
GLIB2_CFLAGS = `pkg-config --cflags glib-2.0` `pkg-config --cflags gio-unix-2.0`
GLIB2_LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs gio-unix-2.0`

X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib

# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama
INCS = -I. -I/usr/include -I${X11INC} -I${ARGTABLE3_INCLUDE_DIR} ${GLIB2_CFLAGS}
LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -L${ARGTABLE3_LIB_DIR} ${GLIB2_LDFLAGS} -lX11 -lXext -lXrandr -lXinerama -largtable3

# flags
CPPFLAGS += -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
Expand Down
22 changes: 22 additions & 0 deletions dbus/instantlock-dbus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
<!-- Only root user can own the service -->
<policy user="root">
<allow own="org.instantos.instantLock"/>
</policy>

<!-- Allow anyone to invoke methods on server, except SetHostName -->
<policy context="default">
<allow send_destination="org.instantos.instantLock"/>
<allow receive_sender="org.instantos.instantLock"/>
</policy>

<!-- <!-1- Allow everything, including access to SetHostName -1-> -->
<!-- <policy user="root"> -->
<!-- <allow send_destination="org.instantos.instantLock"/> -->
<!-- <allow receive_sender="org.instantos.instantLock"/> -->
<!-- </policy> -->
</busconfig>
46 changes: 46 additions & 0 deletions dbus/org.instantos.instantLOCK.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

<!--
This file contains the definition for the org.instantos.instantLOCK D-Bus interface.
Originally written by Scott Hamilton <sgn.hamilton+dbus@protonmail.com>. It may be copied
freely and modified as needed.
-->

<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<interface name="org.instantos.instantLOCK">
<method name="Lock">
<arg name="message" direction="in" type="s">
<doc:doc>
<doc:summary>The message to print.</doc:summary>
</doc:doc>
</arg>
<arg name="oneKey" direction="in" type="b">
<doc:doc>
<doc:summary>Press any key to unlock.</doc:summary>
</doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>Locks the screen.</doc:para>
</doc:description>
</doc:doc>
</method>

<signal name="Locked">
<doc:doc>
<doc:description>
<doc:para>Emitted if the user locked the screen.</doc:para>
</doc:description>
</doc:doc>
</signal>
<signal name="Unlocked">
<doc:doc>
<doc:description>
<doc:para>Emitted if the user successfully unlocked the screen.</doc:para>
</doc:description>
</doc:doc>
</signal>
</interface>
</node>
3 changes: 3 additions & 0 deletions dbus/org.instantos.instantlock.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=org.instantos.instantLOCK
Exec=@Prefix@/bin/instantlock --dbus
Loading