Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discovery] Fix possible issue with retrieval of permissions from the server #4548

Closed
guruz opened this issue Mar 8, 2016 · 8 comments
Closed
Assignees
Labels
p2-high Escalation, on top of current planning, release blocker ReadyToTest QA, please validate the fix/enhancement type:bug
Milestone

Comments

@guruz
Copy link
Contributor

guruz commented Mar 8, 2016

Detected by @nickvergessen in owncloud/smashbox#134 (comment)

@guruz guruz added type:bug p2-high Escalation, on top of current planning, release blocker labels Mar 8, 2016
@guruz guruz added this to the 2.2.0-current milestone Mar 8, 2016
@ckamm
Copy link
Contributor

ckamm commented Mar 14, 2016

I have verified the code that reads remotePerm from the database. The csync_file_stat_t is nulled correctly and a NULL db value leads to an empty remotePerm, as expected.

@ckamm
Copy link
Contributor

ckamm commented Mar 14, 2016

Relevant lines from the logs at https://gist.github.com/nickvergessen/8f5b8ea746a32a7a934b:

step03:
SyncJournalFileRecord("owner_worker/dir") 
"INSERT OR REPLACE INTO metadata (remotePerm) VALUES ("")

step05:
csync_walker:  directory: owner_worker/dir
_csync_detect_update:  Database entry found, compare:   <-> RDNVW

@ckamm
Copy link
Contributor

ckamm commented Mar 14, 2016

@nickvergessen This is still confusing. It looks like step03 writes NULL, but step05 reads "RDNVW". Could you verify that this is what's going on by running the test only after step03 and then checking the database?

Use something like sqlitebrowser on .csync_journal.db in the sync directory and then look for the "dir" row in the metadata table. What's the value of the remotePerm column?

@nickvergessen
Copy link
Contributor

The permissions are saved as RDNVW in the DB after step 3.
Running oc_sync a second time would fix the faulty permissions.

@ckamm
Copy link
Contributor

ckamm commented Mar 15, 2016

@nickvergessen Thanks!

@ckamm ckamm assigned ckamm and unassigned guruz Mar 15, 2016
@ckamm
Copy link
Contributor

ckamm commented Mar 15, 2016

I think the problem is this code in SqlQuery::bindValue

                // unbound value create a null entry.
                res = SQLITE_OK;

i.e. we don't call sqlite3_bind_null() when we want to produce a null table entry. Since bindings are not cleared by sqlite3_reset() the previous file's bindings are inadvertantly written to the database.

I'll try to reproduce the problem and will then fix it.

ckamm added a commit to ckamm/owncloud-client that referenced this issue Mar 15, 2016
In SQLite bindings are not cleared by sqlite3_reset() calls, so
skipping a sqlite3_bind call to create a NULL value doesn't work,
instead the previous value will be written.

To fix this, I clear all bindings in SqlQuery::reset and make sure
to explicitly bind NULL when desired in SqlQuery::bind.

To make sure there's no confusion about SqlQuery::reset and
sqlite3_reset, I rename our method to reset_and_clear_bindings().
@ckamm ckamm added the ReadyToTest QA, please validate the fix/enhancement label Mar 15, 2016
@nickvergessen
Copy link
Contributor

I just built a new master client, so it includes 7bd4f95

Fixed the issue and my locking test finally passes in all cases 👍

ckamm added a commit that referenced this issue Mar 15, 2016
In SQLite bindings are not cleared by sqlite3_reset() calls, so
skipping a sqlite3_bind call to create a NULL value doesn't work,
instead the previous value will be written.

To fix this, I clear all bindings in SqlQuery::reset and make sure
to explicitly bind NULL when desired in SqlQuery::bind.

To make sure there's no confusion about SqlQuery::reset and
sqlite3_reset, I rename our method to reset_and_clear_bindings().

(cherry picked from commit 7bd4f95)
@dragotin
Copy link
Contributor

great finding @ckamm and @nickvergessen thanks!

@ckamm ckamm closed this as completed Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-high Escalation, on top of current planning, release blocker ReadyToTest QA, please validate the fix/enhancement type:bug
Projects
None yet
Development

No branches or pull requests

4 participants