From f2f6ea5029c6c43dc43d714978daca38c03a8a83 Mon Sep 17 00:00:00 2001 From: toni Date: Sun, 8 Nov 2015 20:28:30 +0100 Subject: - changed dir structure - fixed ipc semaphore/mq stuff --- src/config.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/config.h (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..a7fddc0 --- /dev/null +++ b/src/config.h @@ -0,0 +1,21 @@ +#define AUTHOR "Toni Uhlig" +#define AUTHOR_EMAIL "matzeton@googlemail.com" +#define PKGNAME "naskpass" +#define PKGDESC "A NCurses replacement for cryptsetup's askpass." +#define DEFAULT_FIFO "/lib/cryptsetup/passfifo" +#define SHTDWN_CMD "echo 'o' >/proc/sysrq-trigger" + +#define SEM_GUI "/naskpass-gui" +#define SEM_INP "/naskpass-input" +#define SEM_BSY "/naskpass-busy" +#define SEM_RDY "/naskpass-initialized" +#define MSQ_PWD "/naskpass-passwd" +#define MSQ_INF "/naskpass-info" + +#define IPC_MQSIZ 128 + +#ifdef _VERSION +#define VERSION _VERSION +#else +#define VERSION "unknown" +#endif -- cgit v1.2.3 From dcf8b9b6981d0d21db6edb3265b56c55b39e4ff4 Mon Sep 17 00:00:00 2001 From: toni Date: Mon, 16 Nov 2015 01:18:11 +0100 Subject: waitpid(...) checks now for WIFEXITED instead of WIFSIGNALED --- Makefile.am | 2 +- configure.ac | 2 +- src/aconfig.h.in | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/config.h | 2 - src/main.c | 13 +-- src/ui.c | 2 +- src/ui_elements.c | 11 +- src/ui_ipc.c | 30 ++++-- src/ui_ipc.h | 9 +- tests/mqtest.c | 23 ++++- 10 files changed, 363 insertions(+), 30 deletions(-) create mode 100644 src/aconfig.h.in (limited to 'src/config.h') diff --git a/Makefile.am b/Makefile.am index d682608..1d76541 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,6 @@ clean-local: distclean-local: clean-local rm -f aclocal.m4 config.log config.status configure - rm -f Makefile.in src/Makefile.in src/aconfig.h.in src/aconfig.h.in~ src/*.d + rm -f Makefile.in src/Makefile.in src/aconfig.h.in~ src/*.d rm -rf build autom4te.cache diff --git a/configure.ac b/configure.ac index 3786c0e..943f5cf 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ AC_HEADER_STDC AC_HEADER_STAT AC_HEADER_DIRENT AC_HEADER_ASSERT -AC_CHECK_HEADERS([stdio.h stdlib.h stdbool.h string.h unistd.h errno.h sys/stat.h sys/types.h sys/wait.h fcntl.h semaphore.h time.h mqueue.h]) +AC_CHECK_HEADERS([stdio.h stdlib.h stdbool.h string.h unistd.h errno.h sys/stat.h sys/types.h sys/wait.h fcntl.h semaphore.h time.h mqueue.h alloca.h]) # Checks for typedefs, structures, and compiler characteristics. AC_COMPUTE_INT diff --git a/src/aconfig.h.in b/src/aconfig.h.in new file mode 100644 index 0000000..f690396 --- /dev/null +++ b/src/aconfig.h.in @@ -0,0 +1,299 @@ +/* src/aconfig.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have the header file. */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + +/* Define to 1 if you have the `clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + +/* Define to 1 if you have the `close' function. */ +#undef HAVE_CLOSE + +/* Do NOT change THIS! */ +#undef HAVE_CONFIG + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `fprintf' function. */ +#undef HAVE_FPRINTF + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the `memcpy' function. */ +#undef HAVE_MEMCPY + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mkfifo' function. */ +#undef HAVE_MKFIFO + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MQUEUE_H + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the `open' function. */ +#undef HAVE_OPEN + +/* Define to 1 if you have the `printf' function. */ +#undef HAVE_PRINTF + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_SEMAPHORE_H + +/* Define to 1 if you have the `stat' function. */ +#undef HAVE_STAT + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_STAT_EMPTY_STRING_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strlen' function. */ +#undef HAVE_STRLEN + +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + +/* Define to 1 if you have the `strnlen' function. */ +#undef HAVE_STRNLEN + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the `system' function. */ +#undef HAVE_SYSTEM + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if `fork' works. */ +#undef HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#undef HAVE_WORKING_VFORK + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#undef LSTAT_FOLLOWS_SLASHED_SYMLINK + +/* Define to 1 if assertions should be disabled. */ +#undef NDEBUG + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if the `S_IS*' macros in do not work properly. */ +#undef STAT_MACROS_BROKEN + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Define if using the dmalloc debugging malloc package */ +#undef WITH_DMALLOC + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to `int' if does not define. */ +#undef ssize_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +#undef uint16_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t + +/* Define as `fork' if `vfork' does not work. */ +#undef vfork diff --git a/src/config.h b/src/config.h index a7fddc0..9d72ef3 100644 --- a/src/config.h +++ b/src/config.h @@ -12,8 +12,6 @@ #define MSQ_PWD "/naskpass-passwd" #define MSQ_INF "/naskpass-info" -#define IPC_MQSIZ 128 - #ifdef _VERSION #define VERSION _VERSION #else diff --git a/src/main.c b/src/main.c index 5f0d6e9..8dbe953 100644 --- a/src/main.c +++ b/src/main.c @@ -142,21 +142,22 @@ main(int argc, char **argv) while ( ui_ipc_getvalue(SEM_UI) > 0 || ui_ipc_getvalue(SEM_IN) > 0 ) { ui_ipc_sempost(SEM_BS); if (read(ffd, pbuf, IPC_MQSIZ) >= 0) { - ui_ipc_msgsend(MQ_IF, MSG(MSG_BUSY_FD), strlen(MSG(MSG_BUSY_FD))); + ui_ipc_msgsend(MQ_IF, MSG(MSG_BUSY_FD)); if (run_cryptcreate(pbuf, GETOPT(CRYPT_CMD).str) != 0) { - ui_ipc_msgsend(MQ_IF, MSG(MSG_CRYPTCMD_ERR), strlen(MSG(MSG_CRYPTCMD_ERR))); + ui_ipc_msgsend(MQ_IF, MSG(MSG_CRYPTCMD_ERR)); } - } else if ( ui_ipc_msgrecv(MQ_PW, pbuf, IPC_MQSIZ) != (int)-1 ) { - ui_ipc_msgsend(MQ_IF, MSG(MSG_BUSY), strlen(MSG(MSG_BUSY))); + } else if ( ui_ipc_msgcount(MQ_PW) > 0 ) { + ui_ipc_msgrecv(MQ_PW, pbuf); + ui_ipc_msgsend(MQ_IF, MSG(MSG_BUSY)); if (run_cryptcreate(pbuf, GETOPT(CRYPT_CMD).str) != 0) { - ui_ipc_msgsend(MQ_IF, MSG(MSG_CRYPTCMD_ERR), strlen(MSG(MSG_CRYPTCMD_ERR))); + ui_ipc_msgsend(MQ_IF, MSG(MSG_CRYPTCMD_ERR)); } ui_ipc_semwait(SEM_IN); } ui_ipc_semwait(SEM_BS); usleep(100000); waitpid(child, &c_status, WNOHANG); - if ( WIFSIGNALED(c_status) != 0 ) { + if ( WIFEXITED(c_status) != 0 ) { break; } } diff --git a/src/ui.c b/src/ui.c index 8b3d49f..5581bdc 100644 --- a/src/ui.c +++ b/src/ui.c @@ -203,7 +203,7 @@ ui_thrd(void *arg) pthread_mutex_lock(&mtx_update); while ( ui_ipc_getvalue(SEM_UI) > 0 ) { cnd_ret = pthread_cond_timedwait(&cnd_update, &mtx_update, &wait); - if (--atmout == 0) ui_ipc_semtrywait(SEM_UI); + if (--atmout <= 0) ui_ipc_semtrywait(SEM_UI); pthread_mutex_lock(&mtx_busy); do_ui_update( (cnd_ret == ETIMEDOUT ? true : false) ); pthread_mutex_unlock(&mtx_busy); diff --git a/src/ui_elements.c b/src/ui_elements.c index 27ccea0..b274529 100644 --- a/src/ui_elements.c +++ b/src/ui_elements.c @@ -58,12 +58,12 @@ infownd_update(WINDOW *win, struct txtwindow *tw) } static int -mq_passwd_send(char *passwd, size_t len) +mq_passwd_send(char *passwd) { int ret; ui_ipc_sempost(SEM_IN); - ret = ui_ipc_msgsend(MQ_PW, passwd, len); + ret = ui_ipc_msgsend(MQ_PW, passwd); return ret; } @@ -71,14 +71,17 @@ static int passwd_input_cb(WINDOW *wnd, void *data, int key) { struct input *a = (struct input *) data; + char ipc_buf[IPC_MQSIZ+1]; + memset(ipc_buf, '\0', IPC_MQSIZ+1); switch (key) { case UIKEY_ENTER: deactivate_input(pw_input); - mq_passwd_send(a->input, a->input_len); + mq_passwd_send(a->input); clear_input(wnd, a); + ui_ipc_msgrecv(MQ_IF, ipc_buf); set_txtwindow_title(infownd, "BUSY"); - set_txtwindow_text(infownd, "BLA"); + set_txtwindow_text(infownd, ipc_buf); set_txtwindow_active(infownd, true); break; case UIKEY_BACKSPACE: diff --git a/src/ui_ipc.c b/src/ui_ipc.c index 9eac79e..cf137e7 100644 --- a/src/ui_ipc.c +++ b/src/ui_ipc.c @@ -1,12 +1,13 @@ #include #include -#include +#include #ifdef SEM_TIMEDWAIT #include #endif #include #include #include +#include #include #include "ui_ipc.h" @@ -35,14 +36,14 @@ ui_ipc_init(int is_master) sp_oflags = O_CREAT | O_EXCL; mq_oflags = O_NONBLOCK | O_CREAT | O_EXCL; crt_flags = S_IRUSR | S_IWUSR; - JMP_IF( msqs[MQ_PW] = mq_open(MSQ_PWD, mq_oflags | O_RDONLY, crt_flags, &m_attr), (mqd_t)-1, error ); - JMP_IF( msqs[MQ_IF] = mq_open(MSQ_INF, mq_oflags | O_WRONLY, crt_flags, &m_attr), (mqd_t)-1, error ); + JMP_IF( msqs[MQ_PW] = mq_open(MSQ_PWD, mq_oflags | O_RDONLY, crt_flags, &m_attr), (mqd_t)-1, error ); + JMP_IF( msqs[MQ_IF] = mq_open(MSQ_INF, mq_oflags | O_WRONLY, crt_flags, &m_attr), (mqd_t)-1, error ); } else { sp_oflags = 0; mq_oflags = 0; crt_flags = 0; - JMP_IF( msqs[MQ_PW] = mq_open(MSQ_PWD, mq_oflags | O_WRONLY, crt_flags, &m_attr), (mqd_t)-1, error ); - JMP_IF( msqs[MQ_IF] = mq_open(MSQ_INF, mq_oflags | O_RDONLY, crt_flags, &m_attr), (mqd_t)-1, error ); + JMP_IF( msqs[MQ_PW] = mq_open(MSQ_PWD, mq_oflags | O_WRONLY, crt_flags, &m_attr), (mqd_t)-1, error ); + JMP_IF( msqs[MQ_IF] = mq_open(MSQ_INF, mq_oflags | O_RDONLY, crt_flags, &m_attr), (mqd_t)-1, error ); } JMP_IF( sems[SEM_UI] = sem_open(SEM_GUI, sp_oflags, crt_flags, 0), SEM_FAILED, error ); JMP_IF( sems[SEM_IN] = sem_open(SEM_INP, sp_oflags, crt_flags, 0), SEM_FAILED, error ); @@ -117,14 +118,25 @@ ui_ipc_semtimedwait(enum UI_IPC_SEM e_sp, int timeout) #endif int -ui_ipc_msgsend(enum UI_IPC_MSQ e_mq, const char *msg_ptr, size_t msg_len) +ui_ipc_msgsend(enum UI_IPC_MSQ e_mq, const char *msg_ptr) { - return ( mq_send(msqs[e_mq], msg_ptr, msg_len, 0) ); + char *tmp = alloca(IPC_MQSIZ); + memset(tmp, '\0', IPC_MQSIZ); + strncpy(tmp, msg_ptr, IPC_MQSIZ); + return ( mq_send(msqs[e_mq], tmp, IPC_MQSIZ, 0) ); } ssize_t -ui_ipc_msgrecv(enum UI_IPC_MSQ e_mq, char *msg_ptr, size_t msg_len) +ui_ipc_msgrecv(enum UI_IPC_MSQ e_mq, char *msg_ptr) { - return ( mq_receive(msqs[e_mq], msg_ptr, msg_len, NULL) ); + return mq_receive(msqs[e_mq], msg_ptr, IPC_MQSIZ, NULL); } +long +ui_ipc_msgcount(enum UI_IPC_MSQ e_mq) +{ + struct mq_attr m_attr; + bzero(&m_attr, sizeof(struct mq_attr)); + if (mq_getattr(msqs[e_mq], &m_attr) != 0) return -1; + return m_attr.mq_curmsgs; +} diff --git a/src/ui_ipc.h b/src/ui_ipc.h index 2c5bcb5..ec36f35 100644 --- a/src/ui_ipc.h +++ b/src/ui_ipc.h @@ -4,6 +4,8 @@ #include "status.h" #include "config.h" +#define IPC_MQSIZ 128 + enum UI_IPC_SEM { SEM_RD = 0, /* UI Init done? */ @@ -44,9 +46,12 @@ ui_ipc_semtimedwait(enum UI_IPC_MSQ e_sp, int timeout); #endif int -ui_ipc_msgsend(enum UI_IPC_MSQ e_mq, const char *msg_ptr, size_t msg_len); +ui_ipc_msgsend(enum UI_IPC_MSQ e_mq, const char *msg_ptr); ssize_t -ui_ipc_msgrecv(enum UI_IPC_MSQ e_mq, char *msg_ptr, size_t msg_len); +ui_ipc_msgrecv(enum UI_IPC_MSQ e_mq, char *msg_ptr); + +long +ui_ipc_msgcount(enum UI_IPC_MSQ e_mq); #endif diff --git a/tests/mqtest.c b/tests/mqtest.c index e9bc8e7..f2808c8 100644 --- a/tests/mqtest.c +++ b/tests/mqtest.c @@ -1,18 +1,22 @@ #include #include +#include #include #include #include +#include #include #include static mqd_t mq_test; +static mqd_t mq_recv; static const size_t bufsiz = 256; int main(int argc, char **argv) { + int c_stat; struct mq_attr m_attr; char buf[bufsiz], recv[bufsiz]; unsigned int prio; @@ -31,10 +35,10 @@ int main(int argc, char **argv) mq_unlink("/testmq"); assert( (mq_test = mq_open( "/testmq", O_NONBLOCK | O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRWXG, &m_attr )) != (mqd_t)-1 ); assert( mq_getattr(mq_test, &m_attr) == 0 ); - printf("flags.........: %ld\n" - "maxmsg........: %ld\n" - "msgsize.......: %ld\n" - "curmsg........: %ld\n", + printf("flags..........: %ld\n" + "maxmsg.........: %ld\n" + "msgsize........: %ld\n" + "curmsg.........: %ld\n", m_attr.mq_flags, m_attr.mq_maxmsg, m_attr.mq_msgsize, m_attr.mq_curmsgs); strcpy(buf, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVQXYZ"); @@ -44,6 +48,17 @@ int main(int argc, char **argv) printf("SENT(%03lu bytes): %s\n", (long unsigned int) strlen(buf), buf); printf("RECV(%03lu bytes): %s\n", (long unsigned int) sz_recv, recv); + memset(recv, '\0', bufsiz); + if (fork() > 0) { + assert( (mq_recv = mq_open( "/testmq", O_RDONLY, S_IRWXU | S_IRWXG, &m_attr )) != (mqd_t)-1 ); + assert ( (sz_recv = mq_receive(mq_recv, recv, bufsiz, &prio)) > 0 ); + printf("RECV(%03lu bytes): %s\n", (long unsigned int) sz_recv, recv); + return 0; + } + printf("SENT(%03lu bytes): %s\n", (long unsigned int) strlen(buf), buf); + assert ( mq_send(mq_test, buf, bufsiz, 0) == 0 ); + wait(&c_stat); + return 0; } -- cgit v1.2.3 From 089551924a7c6bae2b03bee9999e5563f9267571 Mon Sep 17 00:00:00 2001 From: toni Date: Mon, 16 Nov 2015 23:18:45 +0100 Subject: (auto(conf|make)|dpkg) versioning fix (src/version.h shows the DEFINITIVE version of the pkg) --- .gitignore | 1 + Makefile.am | 5 +++++ Makefile.debug | 8 ++------ configure.ac | 6 +++++- debian/rules | 4 +++- src/Makefile.am | 2 +- src/config.h | 8 +++++--- 7 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/config.h') diff --git a/.gitignore b/.gitignore index dc4c5e9..e233e82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /naskpass +/src/version.h /tests/producer /tests/consumer /tests/semtest diff --git a/Makefile.am b/Makefile.am index 1d76541..5b9f08b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,10 @@ SUBDIRS = src +install-exec-local: + /bin/mkdir -p '$(prefix)/lib/cryptsetup' + /usr/bin/install -c src/naskpass '$(prefix)/lib/cryptsetup/naskpass' + rm '$(prefix)/bin/naskpass' + rmdir '$(prefix)/bin' clean-local: rm -f naskpass diff --git a/Makefile.debug b/Makefile.debug index 66bf8e0..2faf3b2 100644 --- a/Makefile.debug +++ b/Makefile.debug @@ -3,7 +3,6 @@ LDFLAGS = $(shell ncurses5-config --libs) -pthread -lrt CC = gcc INSTALL = install STRIP = strip -VERSION = $(shell if [ -d ./.git ]; then echo -n "git-"; git rev-parse --short HEAD; else echo "1.2a"; fi) BIN = naskpass SOURCES = $(wildcard src/*.c) OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) @@ -12,7 +11,7 @@ DEPS = $(patsubst %.c,%.d,$(SOURCES)) all: $(OBJECTS) $(BIN) %.o: %.c - $(CC) $(CFLAGS) -D_VERSION=\"$(VERSION)\" -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ $(BIN): $(SOURCES) $(CC) $(LDFLAGS) $(OBJECTS) -o $(BIN) @@ -46,7 +45,4 @@ clean: rm -f $(BIN) $(MAKE) -C tests clean -source: - -dh_make --createorig -p naskpass_$(VERSION) -s -y - -.PHONY: all install clean +.PHONY: all debug release strip install uninstall clean diff --git a/configure.ac b/configure.ac index 943f5cf..dc50072 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # AC_PREREQ([2.67]) -AC_INIT([naskpass], [0.01], [matzeton@googlemail.com]) +AC_INIT([naskpass], [0], [matzeton@googlemail.com]) AC_CONFIG_AUX_DIR([build]) AM_INIT_AUTOMAKE([1.11 foreign no-define -Wall -Werror]) AM_WITH_DMALLOC @@ -66,3 +66,7 @@ AC_SUBST([AM_LDFLAGS]) AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT +echo "Run 'make' to finish the process." +test -d .git && VERSION="git-$(git rev-parse --short HEAD)" +echo "#define VERSION \"${VERSION}\"" >src/version.h + diff --git a/debian/rules b/debian/rules index 048a2ae..5cdc77d 100755 --- a/debian/rules +++ b/debian/rules @@ -10,6 +10,7 @@ configure-stamp: dh_testdir ./autogen.sh ./configure + echo "#define VERSION \"$(DEBVERS)\"" >src/version.h touch configure-stamp build: configure-stamp build-stamp @@ -30,7 +31,8 @@ distclean: build install: build dh_testdir dh_testroot - dh_clean -k + dh_clean + dh_prep dh_installdirs $(MAKE) install prefix=$(CURDIR)/debian/naskpass mkdir -p $(CURDIR)/debian/naskpass/usr/share/naskpass diff --git a/src/Makefile.am b/src/Makefile.am index 07b4cfa..aab865c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,3 @@ bin_PROGRAMS=naskpass -naskpass_SOURCES=main.c opt.c status.c ui_ani.c ui.c ui_elements.c ui_input.c ui_ipc.c ui_nwindow.c ui_statusbar.c +naskpass_SOURCES=main.c opt.c status.c ui_ani.c ui.c ui_elements.c ui_input.c ui_ipc.c ui_txtwindow.c ui_statusbar.c diff --git a/src/config.h b/src/config.h index 9d72ef3..797376f 100644 --- a/src/config.h +++ b/src/config.h @@ -12,8 +12,10 @@ #define MSQ_PWD "/naskpass-passwd" #define MSQ_INF "/naskpass-info" -#ifdef _VERSION -#define VERSION _VERSION -#else +#ifdef HAVE_CONFIG_H +#include "version.h" +#endif + +#ifndef VERSION #define VERSION "unknown" #endif -- cgit v1.2.3