Skip to content

Unable to enroll second device after enrolling one device (with nanomdm) #232

Description

@ashishmeher216

I am getting the error:
remove depot\serial: The process cannot access the file because it is being used by another process.

Is anyone else also facing the same? I read some other issue about data races and it is fixed. #185

From my analysis, the error seems to originate from from writeSerial() function defined in depot/file/depot.go.

func (d *fileDepot) writeSerial(serial *big.Int) error {
if err := os.MkdirAll(d.dirPath, 0755); err != nil {
fmt.Println("🚀 ~ file: depot.go:314 ~ iferr:=os.MkdirAll ~ err:", err)
return err
}
name := d.path("serial")
fmt.Println("🚀 ~ file: depot.go:318 ~ func ~ name:", name) // depot/serial
err := os.Remove(name)
fmt.Println("🚀 ~ file: depot.go:332 ~ func ~ Remove: Removing serial file")
fmt.Println("🚀 ~ file: depot.go:319 ~ func ~ err:", err) // getting error here

file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, serialPerm)
if err != nil {
	return err
}
defer file.Close()

if _, err := file.WriteString(fmt.Sprintf("%x\n", serial.Bytes())); err != nil {
	os.Remove(name)
	return err
}
return nil

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions