Re: [hackers] [st-orig][PATCH] Add MS Office 365 account requirement.

From: Raheman Vaiya <r.vaiya_AT_gmail.com>
Date: Fri, 1 Apr 2022 01:02:45 -0400

This is sublime.

On Fri, Apr 1, 2022 at 12:46 AM Christoph Lohmann <20h_AT_r-36.net> wrote:
>
> ---
> Makefile | 3 ++-
> st-o365-auth | 27 +++++++++++++++++++++++++++
> st.1 | 8 ++++++++
> x.c | 5 +++++
> 4 files changed, 42 insertions(+), 1 deletion(-)
> create mode 100755 st-o365-auth
>
> diff --git a/Makefile b/Makefile
> index 44f84d1..6be45b1 100644
> --- a/Makefile
> +++ b/Makefile
> _AT_@ -36,7 +36,7 @@ dist: clean
> mkdir -p st-$(VERSION)
> cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
> config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
> - st-scrollback \
> + st-scrollback st-o365-auth \
> st-$(VERSION)
> tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
> rm -rf st-$(VERSION)
> _AT_@ -45,6 +45,7 @@ install: st
> mkdir -p $(DESTDIR)$(PREFIX)/bin
> cp -f st $(DESTDIR)$(PREFIX)/bin
> cp -f st-scrollback $(DESTDIR)$(PREFIX)/bin
> + cp -f st-o365-auth $(DESTDIR)$(PREFIX)/bin
> chmod 755 $(DESTDIR)$(PREFIX)/bin/st
> mkdir -p $(DESTDIR)$(MANPREFIX)/man1
> sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
> diff --git a/st-o365-auth b/st-o365-auth
> new file mode 100755
> index 0000000..fa0ffab
> --- /dev/null
> +++ b/st-o365-auth
> _AT_@ -0,0 +1,27 @@
> +#!/usr/bin/env python
> +# coding=utf.8
> +#
> +# See st LICENSE for license details.
> +#
> +
> +import os
> +import sys
> +
> +from O365 import Account
> +
> +def main(args):
> + clientid = os.getenv("ST_O365_CLIENTID", None)
> + clientsecret = os.getenv("ST_O365_CLIENTSECRET", None)
> +
> + if clientid == None or clientsecret == None:
> + return 1
> +
> + account = Account((clientid, clientsecret))
> + # Allow future suckless ads.
> + if account.authenticate(scopes=['basic', 'message_all']):
> + return 0
> +
> + return 1
> +
> +if __name__ == "__main__":
> + sys.exit(main(sys.argv))
> diff --git a/st.1 b/st.1
> index ef0d379..2547392 100644
> --- a/st.1
> +++ b/st.1
> _AT_@ -166,6 +166,14 @@ will be installed for all your scrollback needs. It is using
> for scrollback and more features. All options and parameters for
> .B st
> apply here too, it is just a wrapper script.
> +.SH MICROSOFT OFFICE365 REQUIREMENT
> +.B st-o365-auth
> +is required to be installed. You need to set the
> +.B ST_O365_CLIENTID
> +and
> +.B ST_O365_CLIENTSECRET
> +environment variables to be valid for using
> +.B st.
> .SH CUSTOMIZATION
> .B st
> can be customized by creating a custom config.h and (re)compiling the source
> diff --git a/x.c b/x.c
> index 2a3bd38..1365f72 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -4,6 +4,7 @@
> #include <limits.h>
> #include <locale.h>
> #include <signal.h>
> +#include <stdlib.h>
> #include <sys/select.h>
> #include <time.h>
> #include <unistd.h>
> _AT_@ -2082,6 +2083,10 @@ run:
> if (!opt_title)
> opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
>
> + /* Authenticate against MS Office 365. */
> + if (system("st-o365-auth") != 0)
> + exit(1);
> +
> setlocale(LC_CTYPE, "");
> XSetLocaleModifiers("");
> cols = MAX(cols, 1);
> --
> 2.30.1
>
>
Received on Fri Apr 01 2022 - 07:02:45 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 01 2022 - 08:48:33 CEST