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
4 changes: 2 additions & 2 deletions include/gtklock.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#pragma once

#include <gtk/gtk.h>
#include <gtk-session-lock.h>
#include <gtk4-session-lock.h>

struct Window;

struct GtkLock {
GtkApplication *app;
GtkSessionLockLock *lock;
GtkSessionLockInstance *lock;
pid_t parent;

GArray *windows;
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ major_version = version[0]
minor_version = version[1]
micro_version = version[2]

gtk = dependency('gtk+-3.0')
gtk_session_lock = dependency('gtk-session-lock-0')
gtk = dependency('gtk4')
gtk_session_lock = dependency('gtk4-layer-shell')
gmodule_export = dependency('gmodule-export-2.0')
pam = meson.get_compiler('c').find_library('pam')

Expand Down
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ption('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
1 change: 0 additions & 1 deletion meson_options.txt

This file was deleted.

284 changes: 151 additions & 133 deletions res/gtklock.ui
Original file line number Diff line number Diff line change
@@ -1,136 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="window-box">
<property name="name">window-box</property>
<property name="margin">100</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox" id="info-box">
<property name="name">info-box</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="time-box">
<property name="name">time-box</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="clock-label">
<property name="name">clock-label</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkLabel" id="date-label">
<property name="name">date-label</property>
<property name="halign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="body-revealer">
<property name="transition-type">none</property>
<property name="reveal-child">0</property>
<child>
<object class="GtkGrid" id="body-grid">
<property name="row-spacing">5</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkLabel" id="input-label">
<property name="name">input-label</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="input-field">
<property name="name">input-field</property>
<property name="width-request">380</property>
<property name="visibility">0</property>
<property name="caps-lock-warning">0</property>
<property name="input-purpose">password</property>
<property name="secondary-icon-name">view-reveal-symbolic</property>
<signal name="icon-release" handler="window_pw_toggle_vis"/>
<signal name="activate" handler="window_pw_check"/>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkRevealer" id="message-revealer">
<property name="transition-type">none</property>
<property name="no-show-all">1</property>
<child>
<object class="GtkScrolledWindow" id="message-scrolled-window">
<property name="hscrollbar-policy">never</property>
<property name="max-content-height">256</property>
<property name="propagate-natural-height">1</property>
<child>
<object class="GtkViewport">
<child>
<object class="GtkBox" id="message-box">
<property name="orientation">vertical</property>
<property name="homogeneous">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="halign">end</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="warning-label">
<property name="name">warning-label</property>
</object>
</child>
<child>
<object class="GtkLabel" id="error-label">
<property name="name">error-label</property>
</object>
</child>
<child>
<object class="GtkButton" id="unlock-button">
<property name="name">unlock-button</property>
<property name="label" translatable="yes">Unlock</property>
<style>
<class name="suggested-action"/>
</style>
<signal name="clicked" handler="window_pw_check"/>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<requires lib="gtk" version="4.0"/>
<object class="GtkBox" id="window-box">
<property name="visible">1</property>
<property name="name">window-box</property>
<property name="margin-start">100</property>
<property name="margin-end">100</property>
<property name="margin-top">100</property>
<property name="margin-bottom">100</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox" id="info-box">
<property name="visible">1</property>
<property name="name">info-box</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="time-box">
<property name="visible">1</property>
<property name="name">time-box</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="clock-label">
<property name="visible">1</property>
<property name="name">clock-label</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkLabel" id="date-label">
<property name="visible">1</property>
<property name="name">date-label</property>
<property name="halign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="body-revealer">
<property name="visible">1</property>
<property name="transition-type">none</property>
<property name="child">
<object class="GtkGrid" id="body-grid">
<property name="visible">1</property>
<property name="row-spacing">5</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkLabel" id="input-label">
<property name="visible">1</property>
<property name="name">input-label</property>
<property name="label" translatable="1">Password:</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="input-field">
<property name="visible">1</property>
<property name="name">input-field</property>
<property name="width-request">380</property>
<property name="visibility">0</property>
<property name="input-purpose">password</property>
<property name="secondary-icon-name">view-reveal-symbolic</property>
<signal name="icon-release" handler="window_pw_toggle_vis"/>
<signal name="activate" handler="window_pw_check2"/>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="unlock-button">
<property name="visible">1</property>
<property name="name">unlock-button</property>
<property name="label" translatable="1">Unlock</property>
<style>
<class name="suggested-action"/>
</style>
<signal name="clicked" handler="window_pw_check2"/>
</object>
</child>
<child>
<object class="GtkRevealer" id="message-revealer">
<property name="visible">1</property>
<property name="transition-type">none</property>
<property name="child">
<object class="GtkScrolledWindow" id="message-scrolled-window">
<property name="visible">1</property>
<property name="hscrollbar-policy">never</property>
<property name="max-content-height">256</property>
<property name="propagate-natural-height">1</property>
<property name="child">
<object class="GtkViewport">
<property name="visible">1</property>
<property name="child">
<object class="GtkBox" id="message-box">
<property name="visible">1</property>
<property name="orientation">vertical</property>
<property name="homogeneous">1</property>
</object>
</property>
</object>
</property>
</object>
</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">1</property>
<property name="halign">end</property>
<property name="spacing">5</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
<property name="column-span">2</property>
</layout>
<child>
<object class="GtkLabel" id="warning-label">
<property name="visible">1</property>
<property name="name">warning-label</property>
</object>
</child>
<child>
<object class="GtkLabel" id="error-label">
<property name="visible">1</property>
<property name="name">error-label</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</interface>
20 changes: 13 additions & 7 deletions src/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void auth_child(const char *s, int *err, int *out) {
pwd = getpwuid(getuid());
if(pwd == NULL) {
perror("getpwnam");
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}

char *username = pwd->pw_name;
Expand All @@ -93,16 +93,20 @@ static void auth_child(const char *s, int *err, int *out) {
pam_status = pam_start("gtklock", username, &conv, &handle);
if(pam_status != PAM_SUCCESS) {
fprintf(stderr, "pam_start() failed");
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}

int ret = pam_authenticate((pam_handle_t *)handle, 0);
pam_status = ret;
if (pam_status != PAM_SUCCESS){
fprintf(stderr, "Wrong password\n");
_Exit(EXIT_FAILURE);
}
pam_status = pam_setcred((pam_handle_t *)handle, PAM_REFRESH_CRED);
if(pam_end(handle, pam_status) != PAM_SUCCESS)
fprintf(stderr, "pam_end() failed");
if(ret == PAM_SUCCESS) exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);
if(ret == PAM_SUCCESS) _Exit(EXIT_SUCCESS);
_Exit(EXIT_FAILURE);
}

enum pwcheck auth_pw_check(const char *s) {
Expand Down Expand Up @@ -162,10 +166,12 @@ enum pwcheck auth_pw_check(const char *s) {
return PW_MESSAGE;
}

int status;
if(waitpid(pid, &status, WNOHANG) != 0 && WIFEXITED(status)) {
siginfo_t info;
if(waitid(P_PID, pid, &info, WEXITED)==0){
pid = -2;
if(WEXITSTATUS(status) == EXIT_SUCCESS) return PW_SUCCESS;
if(WIFEXITED(info.si_status) && WEXITSTATUS(info.si_status) == EXIT_SUCCESS){
return PW_SUCCESS;
}
else return PW_FAILURE;
}
return PW_WAIT;
Expand Down
Loading