Skip to content

Commit

Permalink
Merge branch 'branches/rudder/8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Oct 28, 2024
2 parents dfa8bc9 + 1085d57 commit 93d0f89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion policies/module-types/system-updates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@ The APT support is enabled with the `apt` feature:

```shell
cargo build --release --features=apt
```
```

### Security

This module needs to run as root, and protects its database with `600` permissions.
16 changes: 11 additions & 5 deletions policies/module-types/system-updates/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ impl PackageDatabase {
rudder_debug!("Running pid migration");
let r = self
.conn
.execute("select pid from update_events limit 1", ());
if r.is_err() {
rudder_debug!("Adding the pid column");
self.conn
.execute("alter table update_events add pid integer", ())?;
.query_row("select pid from update_events limit 1", [], |_| Ok(()));
match r {
Ok(_) => (),
Err(rusqlite::Error::QueryReturnedNoRows) => (),
Err(_) => {
rudder_debug!("Adding the pid column");
self.conn
.execute("alter table update_events add pid integer", ())?;
}
}
Ok(())
}
Expand Down Expand Up @@ -372,6 +376,8 @@ mod tests {

let mut db = PackageDatabase::open_existing(conn);
db.migration_add_pid().unwrap();
// can run twice
db.migration_add_pid().unwrap();

let conn = db.into_connection();
let r = conn.execute("select pid from update_events", ());
Expand Down

0 comments on commit 93d0f89

Please sign in to comment.