Bug 447961 - KDE Partition Manager deletes davfs entry from /etc/fstab
Summary: KDE Partition Manager deletes davfs entry from /etc/fstab
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (other bugs)
Version First Reported In: 21.08.1
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-05 08:48 UTC by Michael Ehrlichman
Modified: 2022-01-05 23:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In: 22.04.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Ehrlichman 2022-01-05 08:48:46 UTC
SUMMARY

If I use KDE Partition Manager to edit any of my mount points, it replaces the following /etc/fstab with a blank line.

https://<redact>/<redact/<redact> /home/<redact>/dav davfs _netdev,noexec,nosuid,user,uid=<redact> 0 3

Ubuntu 21.10
Kernel 5.16.0-051600rc8-generic
partitionmanager 21.08.1


STEPS TO REPRODUCE
1.  Use editor (eg vim) to add davfs line like the above to /etc/fstab
2.  Use KDE partition manager to edit any mount point
3.  Observe that /etc/fstab now contains a blank line where the davfs entry used to be.

OBSERVED RESULT
davfs entry deleted

EXPECTED RESULT
davfs entry unchanged

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 21.10
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.16.0-051600rc8-generic (64-bit)
Graphics Platform: X11
Processors: 10 × 12th Gen Intel® Core™ i5-12600K
Memory: 30.7 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Comment 1 Andrius Štikonas 2022-01-05 10:29:21 UTC
Does URL contain any # characters?
Comment 2 Michael Ehrlichman 2022-01-05 18:44:22 UTC
The davfs entry does not contain # characters.  Here is a less redacted fstab entry:

https://abdc.net/remote.php/webdav/myfolder /home/einstein/myfolder davfs _netdev,noexec,nosuid,user,uid=einstein  0 3
Comment 3 Andrius Štikonas 2022-01-05 18:55:37 UTC
(In reply to Michael Ehrlichman from comment #2)
> The davfs entry does not contain # characters.  Here is a less redacted
> fstab entry:
> 
> https://abdc.net/remote.php/webdav/myfolder /home/einstein/myfolder davfs
> _netdev,noexec,nosuid,user,uid=einstein  0 3

Thanks. Hmm right now I don't immediately see what's going wrong here.
I thought # might be tripping in one of these two lines
https://invent.kde.org/system/kpmcore/-/blob/master/src/core/fstab.cpp#L71
https://invent.kde.org/system/kpmcore/-/blob/master/src/core/fstab.cpp#L88

but I guess something else is going on.
Comment 4 Michael Ehrlichman 2022-01-05 21:59:44 UTC
Perhaps a clue:  If I put a "/" at the front of the dafvs line  i.e.  replace "https" with "/https" then the bug goes away.

Of course putting a slash there is not a fix, I am simply trying to find clues as to what is wrong with the text processing.
Comment 5 Andrius Štikonas 2022-01-05 22:02:55 UTC
(In reply to Michael Ehrlichman from comment #4)
> Perhaps a clue:  If I put a "/" at the front of the dafvs line  i.e. 
> replace "https" with "/https" then the bug goes away.
> 
> Of course putting a slash there is not a fix, I am simply trying to find
> clues as to what is wrong with the text processing.

I think that suggest bug in
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode)
function. We don't hit any of the "if/else" cases there.
Comment 6 Michael Ehrlichman 2022-01-05 22:16:48 UTC
That sounds right.  As you probably expect, if I prefix the line with "UUID=", then the line is not deleted.

So an addition like the following, or perhaps a check for fsType=='davfs', would work, no? 

    } else if (m_fsSpec.startsWith(QStringLiteral("http"))) {
        m_entryType = FstabEntry::Type::netdev;
        m_deviceNode = m_fsSpec;
Comment 7 Andrius Štikonas 2022-01-05 22:28:24 UTC
(In reply to Michael Ehrlichman from comment #6)
> That sounds right.  As you probably expect, if I prefix the line with
> "UUID=", then the line is not deleted.
> 
> So an addition like the following, or perhaps a check for fsType=='davfs',
> would work, no? 
> 
>     } else if (m_fsSpec.startsWith(QStringLiteral("http"))) {
>         m_entryType = FstabEntry::Type::netdev;
>         m_deviceNode = m_fsSpec;

Hmm, perhaps just setting m_deviceNode = m_fsSpec before all those if/else blocks work, let me test.
Comment 8 Andrius Štikonas 2022-01-05 22:45:39 UTC
(In reply to Andrius Štikonas from comment #7)
> (In reply to Michael Ehrlichman from comment #6)
> > That sounds right.  As you probably expect, if I prefix the line with
> > "UUID=", then the line is not deleted.
> > 
> > So an addition like the following, or perhaps a check for fsType=='davfs',
> > would work, no? 
> > 
> >     } else if (m_fsSpec.startsWith(QStringLiteral("http"))) {
> >         m_entryType = FstabEntry::Type::netdev;
> >         m_deviceNode = m_fsSpec;
> 
> Hmm, perhaps just setting m_deviceNode = m_fsSpec before all those if/else
> blocks work, let me test.

Actually it looks like things are going wrong during write stage:
https://invent.kde.org/system/kpmcore/-/blob/master/src/core/fstab.cpp#L280
Comment 9 Andrius Štikonas 2022-01-05 23:01:12 UTC
Git commit 5ffc5c6f238c70735637035456a9484f4f0f41dd by Andrius Štikonas.
Committed on 05/01/2022 at 23:00.
Pushed by stikonas into branch 'master'.

Fix davfs entries being omitted from fstab file.

M  +4    -2    src/core/fstab.cpp
M  +1    -1    src/core/fstab.h

https://invent.kde.org/system/kpmcore/commit/5ffc5c6f238c70735637035456a9484f4f0f41dd