Bug 2462 - [Anolis 23][x86]执行createrepo -S -s sha1 ./报错Unknown/Unsupported checksum type "sha1"
Summary: [Anolis 23][x86]执行createrepo -S -s sha1 ./报错Unknown/Unsupported checksum type...
Status: RESOLVED BYDESIGN
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: Others (show other bugs) Others
Version: 23.0
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: xuchunmei
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-20 17:02 UTC by meil_wei
Modified: 2022-10-25 11:05 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description meil_wei alibaba_cloud_group 2022-10-20 17:02:03 UTC
Description of problem:
执行createrepo -S -s sha1 ./报错Unknown/Unsupported checksum type "sha1"
# createrepo -S -s sha1 ./
Unknown/Unsupported checksum type "sha1"

Steps to Reproduce:
createrepo -S -s sha1 ./

Actual results:
执行报错

Expected results:
执行成功,无报错

Additional info:
# uname -r
5.17.0-1.an23.x86_64

# cat /etc/os-release
NAME="Anolis OS"
VERSION="23"
ID="anolis"
VERSION_ID="23"
PLATFORM_ID="platform:an23"
PRETTY_NAME="Anolis OS 23"
ANSI_COLOR="0;31"
HOME_URL="https://openanolis.cn/"
BUG_REPORT_URL="https://bugzilla.openanolis.cn/"
Comment 1 xuchunmei alibaba_cloud_group 2022-10-20 17:12:39 UTC
从构建记录以及源码分析,createrepo应该不支持SHA1,默认WITH_LEGACY_HASHES=OFF
cr_ChecksumType
cr_checksum_type(const char *name)
{
    size_t len;
    char name_lower[MAX_CHECKSUM_NAME_LEN+1] = {0};

    if (!name)
        return CR_CHECKSUM_UNKNOWN;

    len = strlen(name);
    if (len > MAX_CHECKSUM_NAME_LEN)
        return CR_CHECKSUM_UNKNOWN;

    for (size_t x = 0; x <= len; x++)
        name_lower[x] = tolower(name[x]);

    if (!strncmp(name_lower, "sha", 3)) {
        // SHA* family
        char *sha_type = name_lower + 3;
        if (!strcmp(sha_type, "512"))
            return CR_CHECKSUM_SHA512;
        else if (!strcmp(sha_type, "384"))
            return CR_CHECKSUM_SHA384;
        else if (!strcmp(sha_type, "256"))
            return CR_CHECKSUM_SHA256;
        else if (!strcmp(sha_type, "224"))
            return CR_CHECKSUM_SHA224;
#ifdef WITH_LEGACY_HASHES
        else if (!strcmp(sha_type, ""))
            return CR_CHECKSUM_SHA;
        else if (!strcmp(sha_type, "1"))
            return CR_CHECKSUM_SHA1;
    } else if (!strncmp(name_lower, "md", 2)) {
        // MD* family
        if (name_lower[2] == '5')
            return CR_CHECKSUM_MD5;
#endif
    }

    return CR_CHECKSUM_UNKNOWN;
}
所以使用sha1的方式会报错。从这里看,支持SHA384,SHA256,SHA224
Comment 2 xuchunmei alibaba_cloud_group 2022-10-25 11:05:45 UTC
使用支持的SHA算法测试,如SHA384,SHA256,SHA224。
不支持的SHA算法报错为预期行为。