Skip to content

Commit 50efb65

Browse files
committed
Merge branch 'pu/missing-signed-by' into 'main'
update: Add notice about missing Signed-By in deb822 sources See merge request apt-team/apt!298
2 parents 9ef79ab + aba8139 commit 50efb65

File tree

7 files changed

+47
-2
lines changed

7 files changed

+47
-2
lines changed

apt-pkg/deb/debmetaindex.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,9 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
13971397
Deb->SetSnapshot(GetSnapshotOption(Options, "snapshot")) == false)
13981398
return false;
13991399

1400+
if (GetBoolOption(Options, "sourceslist-entry-is-deb822", false))
1401+
Deb->SetFlag(metaIndex::Flag::DEB822);
1402+
14001403
std::map<std::string, std::string>::const_iterator const signedby = Options.find("signed-by");
14011404
if (signedby == Options.end())
14021405
{

apt-pkg/metaindex.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <vector>
1212
/*}}}*/
1313

14-
class metaIndexPrivate /*{{{*/
14+
struct metaIndexPrivate /*{{{*/
1515
{
16+
int Flags;
1617
};
1718
/*}}}*/
1819

@@ -69,6 +70,8 @@ APT_PURE signed short metaIndex::GetDefaultPin() const { return DefaultPin; }
6970
APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; }
7071
APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
7172
APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
73+
APT_PURE bool metaIndex::HasFlag(metaIndex::Flag Flag) const { return d->Flags & int(Flag); }
74+
void metaIndex::SetFlag(metaIndex::Flag Flag) { d->Flags |= int(Flag); }
7275
APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; }
7376
APT_PURE std::string metaIndex::GetExpectedDist() const { return Dist; }
7477
/*}}}*/

apt-pkg/metaindex.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ class APT_PUBLIC metaIndex
3030
enum APT_HIDDEN TriState {
3131
TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET
3232
};
33-
private:
33+
34+
enum class APT_HIDDEN Flag
35+
{
36+
DEB822 = 0x01,
37+
};
38+
39+
private:
3440
metaIndexPrivate * const d;
3541
protected:
3642
std::vector <pkgIndexFile *> *Indexes;
@@ -74,6 +80,10 @@ class APT_PUBLIC metaIndex
7480
time_t GetValidUntil() const;
7581
time_t GetDate() const;
7682
virtual time_t GetNotBefore() const = 0;
83+
#ifdef APT_COMPILING_APT
84+
bool HasFlag(Flag flag) const;
85+
#endif
86+
void SetFlag(Flag flag) APT_HIDDEN;
7787

7888
std::string GetExpectedDist() const;
7989
bool CheckDist(std::string const &MaybeDist) const;

apt-pkg/sourcelist.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List, /*{{{*/
143143
Options["sourceslist-entry"] = entry;
144144
}
145145

146+
Options["sourceslist-entry-is-deb822"] = "true";
147+
146148
// now create one item per suite/section
147149
auto const list_uris = FindMultiValue(Tags, "URIs");
148150
auto const list_comp = FindMultiValue(Tags, "Components");

apt-private/private-update.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,20 @@ bool DoUpdate()
233233
}
234234
}
235235

236+
if (_config->FindB("APT::Get::Update::SourceListWarnings::SignedBy", SLWarnings))
237+
{
238+
for (auto *S : *List)
239+
{
240+
if (not S->HasFlag(metaIndex::Flag::DEB822) || not S->GetSignedBy().empty())
241+
continue;
242+
243+
URI uri(S->GetURI());
244+
// TRANSLATOR: the first is manpage reference, the last the URI from a sources.list
245+
_error->Notice(_("Missing Signed-By in the %s entry for '%s'"),
246+
"sources.list(5)", URI::ArchiveOnly(uri).c_str());
247+
}
248+
}
249+
236250
// show basic stats (if the user whishes)
237251
if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true)
238252
{

doc/examples/configure-index

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ APT
130130
{
131131
APTAuth "<BOOL>";
132132
NonFreeFirmware "<BOOL>";
133+
SignedBy "<BOOL>";
133134
};
134135
};
135136
};

test/integration/test-apt-get-update-sourceslist-warning

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ testsuccessequal "$BOILERPLATE" apt update --no-download
3838
echo 'deb-src http://example.org/debian bookworm main non-free' > rootdir/etc/apt/sources.list.d/example.list
3939
testsuccessequal "$BOILERPLATE" apt update --no-download
4040

41+
msgmsg 'Suggest Signed-By for deb822 sources.list(5) entries'
42+
rm rootdir/etc/apt/sources.list.d/example.list
43+
echo 'Types: deb
44+
URIs: http://example.org/debian
45+
Suites: bookworm
46+
Components: main
47+
' > rootdir/etc/apt/sources.list.d/example.sources
48+
testsuccessequal "$BOILERPLATE
49+
N: Missing Signed-By in the sources.list(5) entry for 'http://example.org/debian'" apt update --no-download
50+
rm rootdir/etc/apt/sources.list.d/example.sources
51+
4152
msgmsg 'Is non-free-firmware missing?'
4253
echo 'deb http://example.org/debian bookworm main non-free' > rootdir/etc/apt/sources.list.d/example.list
4354
cat >> rootdir/var/lib/apt/lists/example.org_debian_dists_bookworm_non-free_binary-amd64_Packages <<EOF
@@ -72,3 +83,4 @@ insertinstalledpackage 'firmware-linux-nonfree' 'all' '1'
7283
testsuccessequal "$BOILERPLATE
7384
N: Repository 'Debian bookworm' changed its 'firmware component' value from 'non-free' to 'non-free-firmware'
7485
N: More information about this can be found online in the Release notes at: $NOTESURL" apt update --no-download
86+

0 commit comments

Comments
 (0)