diff --git a/Makefile.in b/Makefile.in index fdeddb4..91474ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -121,7 +121,6 @@ noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS) mkdir -m $(DIR_PERM) -p $(DESTDIR)$(PLUGIN_DIR_PURPLE) install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME) mkdir -m $(DIR_PERM) -p $(DESTDIR)/etc/telegram-purple - install -m $(FILE_PERM) tg-server.tglpub $(DESTDIR)/etc/telegram-purple/server.tglpub # Assume that the user does not use AppStream if she doesn't want icons @for lang in $(LOCALES); do \ mkdir -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \ @@ -133,7 +132,7 @@ noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS) noicon_uninstall: rm -f $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME) rm -f $(DESTDIR)/etc/telegram-purple/server.pub # TODO: Remove this in later versions - rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub + rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub # TODO: Remove this in later versions # TODO: Delete all installed .mo's, no matter what LINGUAS says. @for lang in $(LOCALES); do \ echo "removing $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \ diff --git a/Makefile.mingw b/Makefile.mingw index 8306261..b499647 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -106,7 +106,6 @@ strip: $(PRPL_LIBNAME) install: $(PRPL_LIBNAME) $(LOCALES) mkdir -m $(DIR_PERM) -p $(PLUGIN_DIR_PURPLE) install -m $(FILE_PERM) $(PRPL_LIBNAME) $(PLUGIN_DIR_PURPLE)/$(PRPL_NAME) - install -m $(FILE_PERM) tg-server.tglpub $(DATA_ROOT_DIR_PURPLE)/server.tglpub ifeq ($(COPY_ICONS),no) @echo "Not copying icons due to configure-option --disable-icons." @echo " If you're using Finch, Empathy, or Telepathy, then this is a good idea." diff --git a/README.md b/README.md index 50c50b2..419961a 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,8 @@ https://aur.archlinux.org/packages/telegram-purple/ #### Debian -At the time of writing, the package hasn't been accepted yet. -Please first check if it's already available to you: `sudo apt-get install telegram-purple` - -If this doesn't work because the package doesn't exist (yet), please build it from source. +You can build it from source (see following section) or build a `.deb` file +for your package manager. Building From Source @@ -85,12 +83,6 @@ this indicates that this version is in fact much further than just ##### Debian / Ubuntu -We are working on a Debian package! Please first check if it's already available to you: `sudo apt-get install telegram-purple` - -If the above works, then you should stop here: It is now installed. - -If the above fails: Don't worry, just continue building it by yourself. Next you need to install these dependencies: - sudo apt-get install libgcrypt20-dev libpurple-dev libwebp-dev gettext build-essential @@ -223,17 +215,16 @@ Building the Debian Package If you just need a `.deb`, simply do: sudo apt-get install debhelper - git checkout debian-master - git submodule update --recursive fakeroot ./debian/rules binary -And you're done! The `.deb` is in the directory at which you started. +And you're done! The `telegram-purple_….deb` and `telegram-purple-dbgsym_….deb` files +are in the parent directory. To show some info about it, try this: dpkg --info telegram-purple_*.deb -`debian-master` always points to a version that was submitted to Debian. (Note that this doesn't exist yet, as we haven't released to Debian yet.) -`debian-develop` is the candidate for the next submission. +Please note that installing the debugging symbols (`dbgsym`) +help a lot in troubleshooting, so please do install them, too! #### Debian Maintainers #### @@ -244,16 +235,15 @@ Here's how you can generate a `.orig.tar.gz`: make dist -Note that these are incompatible with the old `debian/genorigtar.sh` -tarballs, and can't be made compatible easily. If you need the tarball -from "back then", see the documentation there. - -This command requires the original tar to exist (and will fail otherwise, -although the error message will be misleading) will build all further files, +The following command requires the original tar to exist, +and will build all further files, specifically `.debian.tar.xz`, `.dsc`, `.deb`, and `.changes`: dpkg-buildpackage +If this fails with a cryptic error message, +first make sure that the `….orig.tar` really is in place. + For the upload, you should use `pbuilder` and similar to build the package in a more minimalistic environment. That covers the official part of the work-flow. @@ -265,6 +255,8 @@ and `.dsc` files, do this: false # Move tar to parent directory, by hand dpkg-source -b . +Note that we no longer actively try to get it into the Debian repository. + 1.3.0 ----- @@ -281,15 +273,11 @@ Discussion / Help As we want to avoid OpenSSL, it has become necessary to replace the PEM file format. This means that if you use a custom pubkey (which you really REALLY shouldn't be doing), you have to adapt, sorry. -We no longer ship `tg-server.pub` (old format), but instead `tg-server.tglpub` (new format). If you have a `.pub` and want to continue using telegram-purple, please use this (hopefully highly portable) tool: [pem2bignum](https://github.com/BenWiederhake/pem2bignum) - -You can also write your own conversion tool if you prefer. The format is really simple: - -1. `e`, the public exponent, encoded as big endian 32 bit fixed length (e.g. `0x00 01 00 01` for 65537) -2. `n_len`, the length of `n` in bytes, encoded as big endian 32 bit fixed length (e.g. `0x00 00 01 00` for a 2048-bit = 256-byte key) -3. `n_raw`, the raw modulus, encoded as big endian, using the previously indicated length (e.g. `0xC1 50 02 3E [248 bytes omitted] 21 79 25 1F` in the case of telegram's public RSA key.) - -If you are interested in developing a non-OpenSSL-licensed converter, look into [insane-triangle-banana](https://github.com/BenWiederhake/insane-triangle-banana). +We no longer read the public key of the Telegram servers from a file. +If you really need a different public key, and know what you're doing +(e.g., connecting to some kind of test environment internal to Telegram, +which also is a very bad idea), you need to find the call to `tgl_set_rsa_key_direct` in `telegram-purple.c`, +and provide the key directly by yourself. FAQ diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..4e08d2e --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,8 @@ +/files +/telegram-purple/ +/telegram-purple.* + +/.debhelper/ +/autoreconf.after +/autoreconf.before +/debhelper-build-stamp diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..f8ad3a9 --- /dev/null +++ b/debian/README.source @@ -0,0 +1,121 @@ +Packing, unpacking, and modifying (as per §4.14) +================================================ + +1. Generate the fully patched source, in a form ready for editing, that + would be built to create Debian packages. + +This step does not need any special attention. The standard invocation +of "dpkg-source -x" does exactly what is needed. + +2. Modify the source and save those modifications so that they will be + applied when building the package. + == AND == +3. Remove source modifications that are currently being applied when +building the package. + +There is no standard procedure for this package. Please note that: +- quilt seems to be the default tool for this kind of work. +- git-buildpackage (gbp) might not work as expected, so I refrained + from trying it for this task. See below. + +So far, issues reported against the project have been resolved quickly +enough to avoid scenarios that usually need the d/patches/ directory. + +4. Generate a *.orig.tar.gz from the git repository, e.g., upgrade the + Debian source package to a new upstream version. + +Easy way: + use the provided orig-tars, e.g., 'telegram-purple_1.2.6.orig.tar.gz' + +Hard way (the procedure used to create these files): + $ git clone --recursive --branch debian-master \ + https://github.com/majn/telegram-purple.git + $ cd telegram-purple + ...$ make dist + +The output should look like this: + Refresh commit.h + ./gen-origtar + mv -f bin/result.tar.gz telegram-purple_deb-v1.2.4-2-161-gb5272d4.orig.tar.gz + +The following approaches do NOT work: +- Github's "download source tar", as this leaves out submodules. +- git-buildpackage (gpb). No support for submodules-within-submodules. + +The file README.md of the project contains some hints about how to +build packages, so here's a cheat sheet: +- Just build a *.deb, ideal for local use: + fakeroot ./debian/rules binary +- Build the package for analysis, e.g. lintian: + dpkg-buildpackage +- Only produce a *.dsc and *.debian.tar.xz file: + ( cd .. && dpkg-source -b telegram-purple ) +- Run pbuilder (needs the previous step): + ( cd .. && sudo pbuilder --build telegram-purple_*.dsc ) + + + +Package name +============ + +At the time of writing (2016-01-03), the Debian repository contained +the following libpurple-backends: +- pidgin-encryption +- pidgin-latex +- pidgin-otr +- pidgin-plugin-pack +- pidgin-privacy-please +So following that tradition, this package would be called "pidgin-telegram". + +However, this would have a lot of disadvantages: +- This is a frontend-agnostic backend that works with Adium, pidgin, + and Finch. We hope that it works nicely with all other frontends, too. + Calling it "pidgin-something" would be highly misleading. +- All error messages and their translations would need to be adapted +- paths would need to change that aren't configurable +- some users are expecting the name to be "telegram-purple" + (at least initially) + +Overall, we consider this a needlessly confusing convention, and +intentionally break with it. + + + +Packaging libtgl separately (as per §4.13) +========================================== + +No. + +So far, ABI-compatibility was broken between virtually every other +commit to libtgl, and the library is still under development. The +latest "stable" release is heavily outdated and can no longer be used +productively (missing features, known breaking bugs, etc.), so if we were to +package tgl we would need to repackage it constantly, with no defined +concept of version, soname, or anything reliable. No other program +(*including* tg-cli) can be expected to use the same version of libtgl +as telegram-purple does. (This might happen every now and then, but +that would be random chance. Finally, it's highly unlikely that someone +installs and uses both telegram-purple and tg-cli.) + +Packaging "tl-parser" or the intermediate "generate" program is also a +bad idea: One *could* do that, but it's only useful for libtgl. So +there is a significant lack of users. + +Note that tl-parser is a relatively (in comparison to the rest of +libtgl) stable, portable application (not library). The output format +hasn't changed in a over a year. If you believe that these six files +will be used by a lot of people, I'll be happy to package tl-parser for +you. However, please note that this would require at least two +packages: tl-parser (binary), tl-parser-dev (headers), and possibly +libtl-parser (common object files). + +In short: there's no set of component that could be packaged in a more +clever way. + + + +About this document +=================== + +This is not written in Markdown. All formatting is in the hope of +making it easy to read. diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..4ed6f08 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,27 @@ +telegram-purple (1.3.1-1) UNRELEASED; urgency=medium + + * New upstream release + * No longer actively try to push it into Debian: too unstable. + If you really want a .deb file, see README.md in the toplevel directory. + + -- Ben Wiederhake Mon, 10 Apr 2017 23:31:32 +0200 + +telegram-purple (1.3.0-1) unstable; urgency=medium + + [ Hugues Morisset ] + * Initial Release (Closes: #833793) + + [ Ben Wiederhake ] + * Please note that due to the format-switch in 1.2.6, the file + /etc/telegram-purple/server.pub is obsolete for all version after it. + It is ignored to allow for smooth transition from old, manual + installations, and may be removed in future versions. + * New upstream release + - Add translations and plural support + - Fix lots of bugs around secret chats (still not perfect, though) + - Fix behavior around hibernation + - Fix display errors and false warnings + - Fix crash on 'unsupported' media + - Support supergroups and channels + + -- Ben Wiederhake Mon, 22 Aug 2016 20:59:47 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..79fd86a --- /dev/null +++ b/debian/control @@ -0,0 +1,42 @@ +Source: telegram-purple +Section: net +Priority: optional +Maintainer: Ben Wiederhake +Uploaders: + Hugues Morisset +Build-Depends: + autotools-dev, + debhelper (>= 9), + dh-autoreconf, + libgcrypt20-dev, + libglib2.0-dev, + libpurple-dev, + libwebp-dev, + pkg-config, + zlib1g-dev +Standards-Version: 3.9.8 +Homepage: https://github.com/majn/telegram-purple +Vcs-Git: https://github.com/majn/telegram-purple.git +Vcs-Browser: https://github.com/majn/telegram-purple + +Package: telegram-purple +Architecture: any +Depends: + ${misc:Depends}, + ${shlibs:Depends} +Suggests: + pidgin | finch +Description: Purple plugin to support Telegram + Plugin for purple which lets you use and manage your Telegram account + like any other account in purple. Some features like self-destruct + messages are currently in development. +X-Comment: Traditionally, this plugin should be named "telegram-pidgin". + However, this plugin is also designed to work with at least Adium, + Finch, and hopefully all other libpurple-frontends, so this name would + be highly misleading. Furthermore, the plugin refers to itself as + "telegram-purple", and changing this (e.g. via a patch) would be highly + non-trivial and fragile. Finally, several users know this plugin under + the name telegram-purple only, so naming the Debian package differently + would be another source of confusion. Thus we intentionally break with + this tradition, and re-used the name telegram-purple from the original + project. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..0ca6da4 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,102 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pidgin-telegram +Source: https://github.com/majn/telegram-purple + +Files: * +Copyright: 2014-2015 Matthias Jentsch + 2014 Vitaly Valtman + 2014 Christopher Althaus + 2014 Markus Endres +License: GPL-2+ + +Files: AppStream/telegram-purple.metainfo.untranslated.xml +Copyright: 2015 Jiri Eischmann +License: GFDL-NIV +License-Grant: + GFDL-1.3 + +Files: debian/* +Copyright: 2015 Hugues Morisset + 2015 Ben Wiederhake +License: GPL-2+ + +Files: tgl/* +Copyright: 2013-2015 Vitaly Valtman + 2015 Matthias Jentsch + 2015 Ben Wiederhake +License: LGPL-2.1+ + +Files: tgl/tl-parser/* +Copyright: 2015 Matthias Jentsch + 2015 Vitaly Valtman + 2015 Christopher Althaus + 2015 Markus Endres +License: GPL-2+ + +Files: tgl/tl-parser/portable_endian.h +Copyright: 2013-2014 Mathias Panzenböck + 2015 PkmX +License: BSD-3-clause or Expat or Apache-2 +License-Grant: + I, Mathias Panzenböck, place this file hereby into the public domain. + Use it at your own risk for whatever you like. In case there are + jurisdictions that don't support putting things in the public domain + you can also consider it to be "dual licensed" under the BSD, MIT and + Apache licenses, if you want to. This code is trivial anyway. Consider + it an example on how to get the endian conversion functions on + different platforms. +FIXME: + This is a tag for the sole purpose and hope that one day, someone + searches for "Fixme" (possibly case-sensitive). Thus, the issue in the + following "Comment" field can be found in both the Debian archive and + the original project. +Comment: + This is a comment from the person who wrote this debian/copyright file. + . + The licensing was obviously meant to be "use whatever". However, we + have to mirror it precisely, and verbatim. I took the freedom to + interprete the terms "the MIT licenses" as "Expat"; "the BSD licenses" + as BSD 3-clause; and "the Apache licenses" as Apache 2.0. I do this + in order to keep the list reasonably small and close enough. However, + someone who understands the legal implications should take a close + look at this. + +License: LGPL-2.1+ + On Debian systems, the complete text of the GNU Lesser General + Public License can be found in "/usr/share/common-licenses/LGPL-2.1". + +License: GPL-2+ + On Debian systems, the complete text of the GNU General Public License + version 2 can be found in "/usr/share/common-licenses/GPL-2". + +License: BSD-3-clause + On Debian systems, the complete text of the Revised BSD License + (3-clause) can be found in "/usr/share/common-licenses/GPL-3". + +License: Apache-2 + On Debian systems, the complete text of version 2.0 of the Apache License + can be found in ‘/usr/share/common-licenses/Apache-2.0’. + +License: GFDL-NIV + On Debian systems, the complete text of version 1.3 of the GNU Free + Document License ‘/usr/share/common-licenses/GFDL-1.3’. + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..62deb04 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +AUTHORS diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..e817abb --- /dev/null +++ b/debian/rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + + +%: + dh $@ --parallel --with autoreconf + +# dh_auto_clean tries to "make distclean", but we don't have that target. +override_dh_auto_clean: + test ! -e Makefile || $(MAKE) clean + +## http://wiki.debian.org/onlyjob/get-orig-source +PKD := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +PKG := $(shell dpkg-parsechangelog -l$(PKD)/changelog --show-field=Source) +VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog --show-field=Version | cut -d- -f1) +.PHONY: get-orig-source +get-orig-source: $(info I: $(PKG)_$(VER)) + @echo "# Downloading for ${PKD}" + uscan --noconf --verbose --rename --destdir=$(CURDIR) \ + --check-dirname-level=0 --force-download --download-version "$(VER)" $(PKD) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..16100bc --- /dev/null +++ b/debian/source/options @@ -0,0 +1 @@ +extend-diff-ignore = "(^|/)(config\.(h|log|status)|Makefile)$" diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..e131c30 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,27 @@ +Bug-Database: https://github.com/majn/telegram-purple/issues/ +Bug-Submit: https://github.com/majn/telegram-purple/issues/new +#Cite-As: telegram-purple +## Intentionally left out, to make sure that we don't accidentally break someone's +## workflow. We err on the side of not prescribing anyone how to cite this work. +#Changelog: https://github.com/majn/telegram-purple/blob/master/CHANGELOG.md +## Intentionally left out as it's already outdated at the time of writing. +#Contact: https://goo.gl/QHttTR +## The development chat group. +## Intentionally left out as the link changes constantly. +## https://github.com/majn/telegram-purple#group-chat +## for a recent link. +#Donation: See 'Contact' +#FAQ: https://github.com/majn/telegram-purple/#faq +## Intentionally left out: no real content yet. +Name: telegram-purple +## Might be superfluous, but I want to confirm that the upstream name is +## indeed telegram-purple, hence the package name in Debian. +Repository: https://github.com/majn/telegram-purple/ +Repository-Browse: https://github.com/majn/telegram-purple/ +Security-Contact: + Main developer: Matthias Jentch + Debian packager: Ben Wiederhake +# Development channel (public): https://goo.gl/QHttTR +## Intentionally left out as the link changes constantly. +## https://github.com/majn/telegram-purple#group-chat +## for a recent link. diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..35a2049 --- /dev/null +++ b/debian/watch @@ -0,0 +1,17 @@ +version=4 +opts="\ + downloadurlmangle=s/tag\/v(.*)$/download\/v$1\/telegram-purple_$1.orig.tar.gz/,\ + filenamemangle=s/.*tag\/v(.*)$/telegram-purple_$1.orig.tar.gz/,\ + uversionmangle=s/-(beta\d*)$/~$1/,\ + " \ + https://github.com/majn/telegram-purple/releases \ + /tag/v([\d\.]*(?:-beta\d*)?) \ + debian \ + uupdate + +# Rationales (from bottom up): +# - There will always be tags of the style "v1.2.5", so search for that +# - The "beta" group must be non-capturing, otherwise uscan tries to concatenate them (e.g. "1.2.3-beta.-beta") +# - Github tars are unusable; use the (hopefully attached) origtar +# - Beta-releases should be ordered before the "main" release (was never relevant so far) +# - Spacing in order to have exactly one rule per line diff --git a/telegram-base.c b/telegram-base.c index 816fe85..0e5ee46 100644 --- a/telegram-base.c +++ b/telegram-base.c @@ -35,68 +35,6 @@ #define STATE_FILE_MAGIC 0x28949a93 #define SECRET_CHAT_FILE_MAGIC 0x37a1988a -static gboolean read_ui32 (int fd, unsigned int *ret) { - typedef char check_int_size[(sizeof (int) >= 4) ? 1 : -1]; - (void) sizeof (check_int_size); - - unsigned char buf[4]; - if (4 != read (fd, buf, 4)) { - return 0; - } - // Ugly but works. - *ret = 0; - *ret |= buf[0]; - *ret <<= 8; - *ret |= buf[1]; - *ret <<= 8; - *ret |= buf[2]; - *ret <<= 8; - *ret |= buf[3]; - return 1; -} - -int read_pubkey_file (const char *name, struct rsa_pubkey *dst) { - // Just to make sure nobody reads garbage. - dst->e = 0; - dst->n_len = 0; - dst->n_raw = NULL; - - int pubkey_fd = open (name, O_RDONLY | O_BINARY); - if (pubkey_fd < 0) { - return 0; - } - - unsigned int e; - unsigned int n_len; - if (!read_ui32 (pubkey_fd, &e) || !read_ui32 (pubkey_fd, &n_len) // Ensure successful reads - || n_len < 128 || n_len > 1024 || e < 5) { // Ensure (at least remotely) sane parameters. - close (pubkey_fd); - return 0; - } - - unsigned char *n_raw = malloc (n_len); - if (!n_raw) { - close (pubkey_fd); - return 0; - } - - gint readret; - readret = read (pubkey_fd, n_raw, n_len); - if (readret <= 0 || (n_len != (guint) readret)) { - free (n_raw); - close (pubkey_fd); - return 0; - } - close (pubkey_fd); - - dst->e = e; - dst->n_len = n_len; - dst->n_raw = n_raw; - - info ("read pubkey file: n_len=%u e=%u", n_len, e); - return 1; -} - void read_state_file (struct tgl_state *TLS) { char *name = 0; name = g_strdup_printf("%s/%s", TLS->base_path, "state"); @@ -440,20 +378,6 @@ gchar *get_config_dir (char const *username) { return dir; } -gchar *get_user_pk_path () { - /* - This can't be conditional on whether or not we're using telepathy, because - then we would need to make sure that `make local_install` also knows about - that location. So we *always* use ${HOME}/.purple/telegram-purple, - even when the other files aren't in this folder. - Note that this is only visible when using Telepathy/Empathy with - local_install, which should be kinda rare anyway (use telepathy-morse!). - */ - return g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, ".purple", - G_DIR_SEPARATOR_S, "telegram-purple", - G_DIR_SEPARATOR_S, user_pk_filename, NULL); -} - gchar *get_download_dir (struct tgl_state *TLS) { assert (TLS->base_path); static gchar *dir; diff --git a/telegram-base.h b/telegram-base.h index 9e4a458..b6d4a4f 100644 --- a/telegram-base.h +++ b/telegram-base.h @@ -22,14 +22,6 @@ #include "telegram-purple.h" -struct rsa_pubkey { - unsigned int e; - unsigned int n_len; - unsigned char *n_raw; -}; - -gboolean read_pubkey_file (const char *name, struct rsa_pubkey *dst); - void read_state_file (struct tgl_state *TLS); void read_auth_file (struct tgl_state *TLS); void write_auth_file (struct tgl_state *TLS); @@ -40,7 +32,6 @@ void write_secret_chat_file (struct tgl_state *TLS); void write_secret_chat_gw (struct tgl_state *TLS, void *extra, int success, struct tgl_secret_chat *E); gchar *get_config_dir (char const *username); -gchar *get_user_pk_path (); gchar *get_download_dir (struct tgl_state *TLS); int tgp_visualize_key (struct tgl_state *TLS, unsigned char* sha1_key); diff --git a/telegram-purple.c b/telegram-purple.c index c403b2d..4c84d06 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -18,6 +18,8 @@ Copyright Matthias Jentsch, Vitaly Valtman, Ben Wiederhake, Christopher Althaus 2014-2015 */ +#include + #include "telegram-purple.h" #include "commit.h" @@ -37,12 +39,6 @@ static void update_secret_chat_handler (struct tgl_state *TLS, struct tgl_secret static void update_on_failed_login (struct tgl_state *TLS); const char *config_dir = "telegram-purple"; -const char *user_pk_filename = "server.tglpub"; -#ifdef WIN32 -const char *pk_path = "server.tglpub"; -#else -const char *pk_path = "/etc/telegram-purple/server.tglpub"; -#endif struct tgl_update_callback tgp_callback = { .new_msg = update_message_handler, @@ -541,46 +537,9 @@ static void tgprpl_login (PurpleAccount * acct) { tgl_set_download_directory (TLS, get_download_dir(TLS)); debug ("base configuration path: '%s'", TLS->base_path); - struct rsa_pubkey pubkey; -#ifdef WIN32 - gchar *global_pk_path = g_strdup_printf("%s/%s", DATADIR, pk_path); -#else - gchar *global_pk_path = g_strdup(pk_path); -#endif - debug ("trying global pubkey at %s", global_pk_path); - gboolean global_pk_loaded = read_pubkey_file (global_pk_path, &pubkey); - g_free(global_pk_path); - - tgl_set_verbosity (TLS, 4); - if (global_pk_loaded) { - info ("using global pubkey"); - tgl_set_rsa_key_direct (TLS, pubkey.e, pubkey.n_len, pubkey.n_raw); - } else { - char *user_pk_path = get_user_pk_path (); - debug ("trying local pubkey at %s", user_pk_path); - gboolean user_pk_loaded = read_pubkey_file (user_pk_path, &pubkey); - - if (user_pk_loaded) { - info ("using local pubkey"); - tgl_set_rsa_key_direct (TLS, pubkey.e, pubkey.n_len, pubkey.n_raw); - } else { - failure ("both didn't work. abort."); - char *cause = g_strdup_printf (_("Unable to sign on as %s: file (public key) not found."), - purple_account_get_username (acct)); - purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, cause); - char *long_hint = g_strdup_printf ( - _("Make sure telegram-purple is installed properly,\n" - "including the .tglpub file.\n" - "If you're running SELinux (e.g. when using Tails),\n" - "try 'make local_install', or simply copy\n" - "%1$s to %2$s."), pk_path, user_pk_path); - purple_notify_message (_telegram_protocol, PURPLE_NOTIFY_MSG_ERROR, cause, - long_hint, NULL, NULL, NULL); - g_free (cause); - g_free (long_hint); - return; - } - } + tgl_set_rsa_key_direct (TLS, tglmp_get_default_e(), + tglmp_get_default_key_len(), + tglmp_get_default_key()); tgl_set_ev_base (TLS, conn); tgl_set_net_methods (TLS, &tgp_conn_methods); diff --git a/telegram-purple.nsi b/telegram-purple.nsi index eadfd46..b6c31d3 100644 --- a/telegram-purple.nsi +++ b/telegram-purple.nsi @@ -92,19 +92,18 @@ Section "MainSection" SEC01 SetOutPath "$PidginDir\locale" File /nonfatal "/oname=bg\LC_MESSAGES\telegram-purple.mo" "po\bg.mo" + File /nonfatal "/oname=cs_CZ\LC_MESSAGES\telegram-purple.mo" "po\cs_CZ.mo" File /nonfatal "/oname=de_DE\LC_MESSAGES\telegram-purple.mo" "po\de_DE.mo" File /nonfatal "/oname=es_AR\LC_MESSAGES\telegram-purple.mo" "po\es_AR.mo" File /nonfatal "/oname=fr\LC_MESSAGES\telegram-purple.mo" "po\fr.mo" File /nonfatal "/oname=it_IT\LC_MESSAGES\telegram-purple.mo" "po\it_IT.mo" File /nonfatal "/oname=nl\LC_MESSAGES\telegram-purple.mo" "po\nl.mo" File /nonfatal "/oname=pl_PL\LC_MESSAGES\telegram-purple.mo" "po\pl_PL.mo" - File /nonfatal "/oname=pt_BR\LC_MESSAGES\telegram-purple.mo" "po\pt_BR.mo" File /nonfatal "/oname=ru_RU\LC_MESSAGES\telegram-purple.mo" "po\ru_RU.mo" File /nonfatal "/oname=sq\LC_MESSAGES\telegram-purple.mo" "po\sq.mo" File /nonfatal "/oname=uk\LC_MESSAGES\telegram-purple.mo" "po\uk.mo" SetOutPath "$PidginDir" - File "/oname=server.tglpub" "tg-server.tglpub" File "${WIN32_DEV_TOP}\libgpg-error-1.12-2\bin\libgpg-error-0.dll" File "${WIN32_DEV_TOP}\libgcrypt-1.6.3\bin\libgcrypt-20.dll" File "${WIN32_DEV_TOP}\libwebp-0.4.3-1\bin\libwebp-5.dll" diff --git a/telegram-purple.nsi.awk-in b/telegram-purple.nsi.awk-in index 3578628..a980292 100644 --- a/telegram-purple.nsi.awk-in +++ b/telegram-purple.nsi.awk-in @@ -94,7 +94,6 @@ Section "MainSection" SEC01 File /nonfatal "/oname=%\LC_MESSAGES\telegram-purple.mo" "po\%.mo" SetOutPath "$PidginDir" - File "/oname=server.tglpub" "tg-server.tglpub" File "${WIN32_DEV_TOP}\libgpg-error-1.12-2\bin\libgpg-error-0.dll" File "${WIN32_DEV_TOP}\libgcrypt-1.6.3\bin\libgcrypt-20.dll" File "${WIN32_DEV_TOP}\libwebp-0.4.3-1\bin\libwebp-5.dll" diff --git a/test/Makefile b/test/Makefile index eaa33c5..2183096 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,6 +16,7 @@ ${PLUGIN_TESTS}: %: test/bin/% test/tmp/user .PHONY: check check: ${PLUGIN_TESTS} test/tmp/user + @echo "'make check' passed." .PHONY: recheck recheck: clean-test check diff --git a/tg-server.tglpub b/tg-server.tglpub deleted file mode 100644 index 2e42cf9..0000000 Binary files a/tg-server.tglpub and /dev/null differ