![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,801
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Prevent Kobo from importing dotfiles/folders
I've made a small hack to prevent Kobo from importing dotfiles/folders. It uses LD_PRELOAD to override the directory syscalls and skip over dotfiles other than .kobo* and .adobe-digital-editions. It only applies to the nickel process. This hack was made to solve the issue mentioned in the firmware thread.
This will survive through firmware upgrades. To remove it, you'll need to wait until I make a script for that, or you can delete /etc/ld.so.preload and /usr/local/geek1011/libhidedir_kobo.so (you can also factory reset). I've done some preliminary tests, and everything seems to work well. See here for the code and more details: https://github.com/geek1011/kobo-mod...o-dotfile-hack . Update for 4.17.13694+: There's now a official config option which can do basically the same thing. If you want, you can still use this hack (it will still work). See near the end of this thread for how to use the config option. The disadvantage of the config option is that it won't persist after a sign out and that it will delete stuff if you don't get it right the first time, but otherwise, after the initial setup, they're pretty much identical. Last edited by geek1011; 10-07-2019 at 02:23 PM. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,801
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
@NiLuJe, can you do a quick review of this?
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,501
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
That's a rather large hammer to hit an annoying nail with, but I haven't got any better idea ^^.
That looks sound at first glance, but I'll take a closer look at it tomorrow ![]() ---- EDIT: Huh. I was wondering about the whole fd -> path mapping, turns out getting the path from a (dir) fd is a fun game... Short of checking what /proc/self/fd/%d points to, nothing really comes to mind... Which is somewhat iffy, so, eh, building a cache from opendir looks like a solid approach ![]() Last edited by NiLuJe; 09-18-2019 at 10:17 PM. |
![]() |
![]() |
![]() |
#4 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,801
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Quote:
The only compatibility issues I see with this approach is if Kobo ever decides to use fdopendir (then we won't be able to see the full path to the dirents, only the names), and if Kobo needs to list another dotfile/dir under /mnt in a future update (but I think this is unlikely) (the dir won't appear, but kobo will still be able to list and access the files under it). The advantages of this approach are that it persists (no chance of an update scanning those files by accident), it doesn't touch any pre-existing files (an update won't override it, it won't break anything else), it can limit itself to nickel only, it has complete control over what it shows/hides, it doesn't need to be updated with nickel, and it won't break anything if it a part of it is deleted (the config file or the library). The only time it'll break something enough to require a manual factory reset (it'll never require a sd reimage, unlike a kernel mod) is if there is a serious bug in the directory filtering code. This also turned out to be less brittle than I originally expected it to be, as I could limit it to nickel, it didn't need to pre-process all the dirents every time a dir was opened, and it didn't need to touch any existing files. Quote:
Also, if you have any ideas for the uninstall script, that'd be helpful (I already know about the self-deleting udev loop hook one, but I'm wondering if there's anything simpler). P.S. I'm probably going to convert the gist into a full repo so I can do automatic builds and code comments on it. P.P.S. FYI, the relevant libnickel symbol is SyncFileSystemCommand::findFilesToParse(QString const&, QStringList&)@0x575308, and the relevant Qt4 class is QDir. Update: I've moved the code from the gist to a repo: https://github.com/geek1011/kobo-mod...o-dotfile-hack. Last edited by geek1011; 09-19-2019 at 12:46 AM. |
||
![]() |
![]() |
![]() |
#5 |
Linux User
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,282
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
|
I tested it on my H2O and it works, so thanks for that.
Not a huge fan of LD_PRELOAD (avoided using it in any of my mods so far). Much less a system-wide one. Ugh. Kobo, what the heck. Why you cracking down on the modder community now. This change is so nonsensical. Hope they will reconsider... |
![]() |
![]() |
Advert | |
|
![]() |
#6 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,801
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
No problem!
Quote:
Also, I just had an idea. Do you think it might be better if instead of checking /proc/self/exe, I checked if libnickel was loaded in the current process (the only disadvantage I see is a potential race condition, but the advantage is is will certainly run on anything which cares about book locations, and nothing else)? Quote:
![]() P.S. I've also decided to split the Makefile into a.Kobo and native one, as the current Makefile looks horrible. |
||
![]() |
![]() |
![]() |
#7 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,801
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Quote:
Last edited by geek1011; 09-19-2019 at 07:57 AM. |
|
![]() |
![]() |
![]() |
#8 |
Linux User
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,282
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
|
So, this is ridiculous.
Kobo imports book from hidden .folder even though I don't want it to. Kobo does NOT import book from NOT hidden folder. Thank you for nothing. In libnickel there's some hardcoded stuff: Code:
.Trash .Trashes .Trash-\d+ So yup... it imports books from ".NotTrash/" but ignores books from "xTrash-123" (x instead . so not hidden in any way). The whole notion of maintaining a list of folder names that should actually be treated like hidden folders is silly. Old system was so much clearer and simpler. Starts with dot? Ignore that. |
![]() |
![]() |
![]() |
#9 |
Linux User
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,282
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
|
they ignore .add (which nobod uses?) but not .adds or .addons
but they also ignore (not hidden) xadd, madd, ladd, ... regexp 101, I guess |
![]() |
![]() |
![]() |
#10 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,501
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
TL;DR:
Code:
ExcludeSyncFolders=\\.(?!kobo|adobe).*? The thing to remember is that this is sandwiched inside a Code:
^/mnt/(sd|onboard)/%1$ ![]() @frostschutz: I think some DEs do use numbered trashes, for some reason, so \.Trash-\d+ would make sense ![]() EDIT: Except that both backslash would need to be escaped here ![]() Last edited by NiLuJe; 09-20-2019 at 12:44 AM. |
![]() |
![]() |
![]() |
#11 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,501
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
That yields a nice:
Code:
Sep 20 01:25:29 nickel: ( 2223.266 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.adds" , matches "\.(?!kobo|adobe).*?" Sep 20 01:25:29 nickel: ( 2223.280 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.foo" , matches "\.(?!kobo|adobe).*?" Sep 20 01:25:29 nickel: ( 2223.282 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.fseventsd" , matches "\.(?!kobo|adobe).*?" Sep 20 01:25:29 nickel: ( 2223.296 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.kobo/certificates" , matches "(.kobo|koboExtStorage)/certificates" Sep 20 01:25:29 nickel: ( 2223.297 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.kobo/dict" , matches "(.kobo|koboExtStorage)/dict" Sep 20 01:25:29 nickel: ( 2223.306 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.kobo/kepub" , matches "(.kobo|koboExtStorage)/kepub" Sep 20 01:25:29 nickel: ( 2223.317 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.niluje" , matches "\.(?!kobo|adobe).*?" Sep 20 01:25:29 nickel: ( 2223.320 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.Spotlight-V100" , matches "\.(?!kobo|adobe).*?" Sep 20 01:25:29 nickel: ( 2223.322 @ 0x16d0b30 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.Trashes" , matches "\.(?!kobo|adobe).*?" Code:
Sep 20 01:12:26 nickel: ( 1440.373 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.adds" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.375 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.adobe-digital-editions" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.380 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.foo" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.382 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.fseventsd" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.383 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.kobo" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.385 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.niluje" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.387 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.Spotlight-V100" , matches "\..*?" Sep 20 01:12:26 nickel: ( 1440.389 @ 0x3585888 / ui.debug) void SyncFileSystemCommand::findFilesToParse(const QString&, QStringList&) skipping "/mnt/onboard/.Trashes" , matches "\..*?" ![]() I suddenly have a lot more free space on my H2O ![]() Last edited by NiLuJe; 09-19-2019 at 11:24 PM. |
![]() |
![]() |
![]() |
#12 |
Linux User
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,282
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
|
|
![]() |
![]() |
![]() |
#13 | |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,501
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Quote:
![]() Last edited by NiLuJe; 09-19-2019 at 09:30 PM. |
|
![]() |
![]() |
![]() |
#14 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,501
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Case in point: https://github.com/NiLuJe/kfmon/comm...25df9a553cf857
![]() (The good news is, tomorrow's OCP packages will handle this automagically. Just need to check the Windows script on an actual Windows and not just PowerShell on Linux...). |
![]() |
![]() |
![]() |
#15 | |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 495
Karma: 356531
Join Date: Jul 2016
Location: 'burta, Canada
Device: Kobo Glo HD
|
Quote:
|
|
![]() |
![]() |
![]() |
Tags |
hack, hidden, import, kobo, ldpreload |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to prevent replacement of cover.jpg in kepubs when sending to Kobo e-reader? | JeanPierre | Kobo Reader | 2 | 01-20-2019 04:57 AM |
Kobo should be incapable to prevent the publishing of a stolen epub? | bathop | General Discussions | 36 | 06-04-2016 05:49 PM |
Arc Importing to Kobo Arc | Roadkill | Kobo Tablets | 2 | 08-04-2013 07:18 AM |
Dragging and Dropping Folders to Kobo | david_e | Kobo Reader | 2 | 10-24-2012 06:20 PM |