Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
apk-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sertonix
apk-tools
Commits
623a2de9
Commit
623a2de9
authored
1 year ago
by
Timo Teräs
Browse files
Options
Downloads
Patches
Plain Diff
audit: report errors as 'e'
parent
cb8c705d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/apk-audit.8.scd
+2
-0
2 additions, 0 deletions
doc/apk-audit.8.scd
src/app_audit.c
+10
-8
10 additions, 8 deletions
src/app_audit.c
with
12 additions
and
8 deletions
doc/apk-audit.8.scd
+
2
−
0
View file @
623a2de9
...
...
@@ -28,6 +28,8 @@ then the affected path. The changes detected are:
:
Directory
added
|
D
:
Directory
added
(
with
non
-
listed
files
/
subdirs
)
|
e
:
error
occured
during
audit
(
e
.
g
.
no
permissions
to
read
file
)
|
M
:
File
metadata
changed
(
uid
,
gid
,
or
mode
)
|
m
...
...
This diff is collapsed.
Click to expand it.
src/app_audit.c
+
10
−
8
View file @
623a2de9
...
...
@@ -127,15 +127,14 @@ static int audit_file(struct audit_ctx *actx,
struct
apk_file_info
fi
;
int
rv
=
0
;
if
(
dbf
==
NULL
)
return
'A'
;
if
(
!
dbf
)
return
'A'
;
if
(
apk_fileinfo_get
(
dirfd
,
name
,
APK_FI_NOFOLLOW
|
APK_FI_XATTR_CSUM
(
dbf
->
acl
->
xattr_csum
.
type
?:
APK_CHECKSUM_DEFAULT
)
|
APK_FI_DIGEST
(
apk_dbf_digest
(
dbf
)),
&
fi
,
&
db
->
atoms
)
!=
0
)
return
-
EPERM
;
return
'e'
;
if
(
dbf
->
csum
.
type
!=
APK_CHECKSUM_NONE
&&
apk_digest_cmp_csum
(
&
fi
.
digest
,
&
dbf
->
csum
)
!=
0
)
...
...
@@ -224,16 +223,23 @@ static int audit_directory_tree_item(void *ctx, int dirfd, const char *name)
struct
audit_ctx
*
actx
=
atctx
->
actx
;
struct
apk_database
*
db
=
atctx
->
db
;
struct
apk_db_dir
*
dir
=
atctx
->
dir
,
*
child
=
NULL
;
struct
apk_db_file
*
dbf
;
struct
apk_file_info
fi
;
int
reason
=
0
;
if
(
bdir
.
len
+
bent
.
len
+
1
>=
sizeof
(
atctx
->
path
))
return
0
;
if
(
apk_fileinfo_get
(
dirfd
,
name
,
APK_FI_NOFOLLOW
,
&
fi
,
&
db
->
atoms
)
<
0
)
return
0
;
memcpy
(
&
atctx
->
path
[
atctx
->
pathlen
],
bent
.
ptr
,
bent
.
len
);
atctx
->
pathlen
+=
bent
.
len
;
bfull
=
APK_BLOB_PTR_LEN
(
atctx
->
path
,
atctx
->
pathlen
);
if
(
apk_fileinfo_get
(
dirfd
,
name
,
APK_FI_NOFOLLOW
,
&
fi
,
&
db
->
atoms
)
<
0
)
{
dbf
=
apk_db_file_query
(
db
,
bdir
,
bent
);
if
(
dbf
)
dbf
->
audited
=
1
;
report_audit
(
actx
,
'e'
,
bfull
,
dbf
?
dbf
->
diri
->
pkg
:
NULL
);
goto
done
;
}
if
(
S_ISDIR
(
fi
.
mode
))
{
int
recurse
=
TRUE
;
...
...
@@ -257,8 +263,6 @@ static int audit_directory_tree_item(void *ctx, int dirfd, const char *name)
}
reason
=
audit_directory
(
actx
,
db
,
child
,
&
fi
);
if
(
reason
<
0
)
goto
done
;
recurse_check:
atctx
->
path
[
atctx
->
pathlen
++
]
=
'/'
;
...
...
@@ -274,7 +278,6 @@ recurse_check:
bfull
.
len
--
;
atctx
->
pathlen
--
;
}
else
{
struct
apk_db_file
*
dbf
;
int
protect_mode
=
determine_file_protect_mode
(
dir
,
name
);
dbf
=
apk_db_file_query
(
db
,
bdir
,
bent
);
...
...
@@ -327,7 +330,6 @@ recurse_check:
goto
done
;
}
if
(
!
reason
)
reason
=
audit_file
(
actx
,
db
,
dbf
,
dirfd
,
name
);
if
(
reason
<
0
)
goto
done
;
report_audit
(
actx
,
reason
,
bfull
,
dbf
?
dbf
->
diri
->
pkg
:
NULL
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment